vfile-update
v2.0.7
Published
Update paths in nested vfile contents.
Downloads
3
Maintainers
Readme
vfile-update
Update paths on nested vfiles
Update nested vfile paths in a given vfile's contents. Both update and update.undo return modified copies of the vfile passed to them and don't affect the original.
install
npm i vfile-update
usage
var vfile = require('vfile')
var update = require('vfile-update')
var file = vfile({
path: 'foo',
contents: [
vfile({
path: 'bar',
contents: [
vfile({
path: 'bar.txt',
contents: 'Bar'
})
]
})
]
})
var updated = update(file)
console.log(updated.contents[0].contents[0].history)
// ['bar.txt', 'foo/bar/bar.txt']
var undone = update.undo(updated)
console.log(undone.contents[0].contents[0].history
// ['bar.txt']
api
update (file)
Creates a copy of file and updates paths on its contents. returns the updated copy of file.
returns VFile
file
VFile
VFile to work on
update#undo (file)
Creates a copy of file and undoes update on sub vfile's history.
returns VFile
file
VFile
License
MIT © Paul Zimmer