This commit is contained in:
29
node_modules/unist-util-visit/index.js
generated
vendored
Normal file
29
node_modules/unist-util-visit/index.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = visit
|
||||
|
||||
var visitParents = require('unist-util-visit-parents')
|
||||
|
||||
var CONTINUE = visitParents.CONTINUE
|
||||
var SKIP = visitParents.SKIP
|
||||
var EXIT = visitParents.EXIT
|
||||
|
||||
visit.CONTINUE = CONTINUE
|
||||
visit.SKIP = SKIP
|
||||
visit.EXIT = EXIT
|
||||
|
||||
function visit(tree, test, visitor, reverse) {
|
||||
if (typeof test === 'function' && typeof visitor !== 'function') {
|
||||
reverse = visitor
|
||||
visitor = test
|
||||
test = null
|
||||
}
|
||||
|
||||
visitParents(tree, test, overload, reverse)
|
||||
|
||||
function overload(node, parents) {
|
||||
var parent = parents[parents.length - 1]
|
||||
var index = parent ? parent.children.indexOf(node) : null
|
||||
return visitor(node, index, parent)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user