🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

async-unist-util-visit

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-unist-util-visit

Recursively walk over unist nodes

1.0.0
latest
Source
npm
Version published
Weekly downloads
460
-24.22%
Maintainers
1
Weekly downloads
 
Created
Source

unist-util-visit Build Status Coverage Status

Unist node visitor. Useful with working with remark or retext.

Installation

npm:

npm install unist-util-visit

unist-util-visit is also available as an AMD, CommonJS, and globals module, uncompressed and compressed.

Usage

Dependencies:

var remark = require('remark');
var visit = require('unist-util-visit');

remark().use(function () {
    return function (ast) {
        visit(ast, 'text', function (node) {
          console.log(node)
        });
    };
}).process('Some _emphasis_, **strongness**, and `code`.');

Yields:

{'type': 'text', 'value': 'Some '}
{'type': 'text', 'value': 'emphasis'}
{'type': 'text', 'value': ', '}
{'type': 'text', 'value': 'strongness'}
{'type': 'text', 'value': ', and '}
{'type': 'text', 'value': '.'}

API

visit(node[, type], visitor[, reverse])

Visit nodes. Optionally by node type. Optionally in reverse.

  • node (Node) — Node to search;

  • type (string, optional) — Node type;

  • visitor (Function) — Visitor invoked when a node is found;

  • reverse (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 node;
  • index (number?) — Position of node in parent;
  • index (Node?) — Parent of node.

Returns: boolean? - When false, visiting is immediately stopped.

License

MIT © Titus Wormer

Keywords

unist

FAQs

Package last updated on 16 Apr 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts