vfile-visit
Convert vfile contents to vfiles and walk over nodes in contents
Converts vfile contents to vfiles if contents is an array. Optionally if a visitor function is supplied, then it will be called on each node in contents breadth first.
install
npm i -S vfile-visit
usage
var visit = var vfile = var foo = console
Outputs:
VFile data: {} messages: history: 'foo' cwd: './' contents: VFile data: {} messages: cwd: './' contents: 'bar'
api
visit (file[, visitor])
file
VFile
| Object
- File or object to walk over
visitor
Function?
- Optional visitor to call while walking over nodes
Returns
- modified copy of VFile
visitor (current, index, parent)
current
VFile
- current node
index
Number
- index of current in parent.contents
parent
VFile
- parent of current node