vfile-update

2.0.7 • Public • Published

vfile-update

Update paths on nested vfiles

Travis Coveralls github David

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

Package Sidebar

Install

npm i vfile-update

Weekly Downloads

1

Version

2.0.7

License

MIT

Unpacked Size

5.86 kB

Total Files

7

Last publish

Collaborators

  • mrzmmr