How to use the unist-util-visit-parents.EXIT function in unist-util-visit-parents

To help you get started, we’ve selected a few unist-util-visit-parents examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aliyun / alibabacloud-console-components / packages / gatsby-theme-console-doc / src / buildtime / remarkPlugins / linkInstructions / remarkPlugin.ts View on Github external
const inst = resolveLinkText(linkTextNode.value)
            if (inst) {
              foundLinkInstruction = true
              Promise.resolve(
                inst.instructionHandler({
                  node,
                  ancestors,
                  instructionParam: inst.instructionParam,
                  linkURL,
                  file,
                })
              ).then(() => res(true))
              // stop traversal because the instruction may change ast.
              // the ast may be **completly different** after this instruction's execution.
              // we will detect next instruction in the **next transform pass**.
              return visit.EXIT
            }
          }
        }
        return visit.CONTINUE
      })
      if (!foundLinkInstruction) res(false) // didn't find any instruction
github syntax-tree / unist-util-visit / index.js View on Github external
'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]

unist-util-visit-parents

unist utility to recursively walk over nodes, with ancestral information

MIT
Latest version published 10 months ago

Package Health Score

77 / 100
Full package analysis