mirror of
https://github.com/nodejs/node.git
synced 2026-12-06 10:08:47 -05:00
Update ESLint to 4.1.0. This fixes a bug that previously prevented us from using the new and stricter indentation checking. Refs: https://github.com/eslint/eslint/issues/8721 PR-URL: https://github.com/nodejs/node/pull/13895 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
unist-util-visit

Unist node visitor. Useful when working with remark, retext, or rehype.
Installation
npm:
npm install unist-util-visit
Usage
var remark = require('remark');
var visit = require('unist-util-visit');
var tree = remark.parse('Some _emphasis_, **importance**, and `code`.');
visit(tree, 'text', visitor);
function visitor(node) {
console.log(node);
}
Yields:
{ type: 'text', value: 'Some ' }
{ type: 'text', value: 'emphasis' }
{ type: 'text', value: ', ' }
{ type: 'text', value: 'importance' }
{ type: 'text', value: ', and ' }
{ type: 'text', value: '.' }
API
visit(node[, type], visitor[, reverse])
Visit nodes. Optionally by node type. Optionally in reverse.
Parameters
node(Node) — Node to searchtype(string, optional) — Node typevisitor(Function) — Visitor invoked when a node is foundreverse(boolean, default:false) — When falsey, checking starts at the first child and continues through to later children. When truthy, this is reversed. This does not mean checking starts at the deepest node and continues on to the highest node
stop? = visitor(node, index, parent)
Invoked when a node (when type is given, matching type) is found.
Parameters
node(Node) — Found nodeindex(number?) — Position ofnodeinparentparent(Node?) — Parent ofnode
Returns
boolean? - When false, visiting is immediately stopped.
Related
unist-util-visit-parents— Likevisit, but with a stack of parentsunist-util-filter— Create a new tree with all nodes that pass a testunist-util-map— Create a new tree with all nodes mapped by a given functionunist-util-remove— Remove nodes from a tree that pass a testunist-util-select— Select nodes with CSS-like selectors