Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mdast-util-visit

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mdast-util-visit

Utility to recursively walk over mdast nodes

  • 0.1.1
  • npm
  • Socket score

Version published
Weekly downloads
103
increased by15.73%
Maintainers
1
Weekly downloads
 
Created
Source

mdast-util-visit Build Status Coverage Status

mdast utility to recursively walk over nodes: both forwards and backwards.

Installation

npm:

npm install mdast-util-visit

mdast-util-visit is also available for bower, component, and duo, and as an AMD, CommonJS, and globals module, uncompressed and compressed.

Usage

/*
 * Dependencies.
 */

var mdast = require('mdast');
var visit = require('mdast-util-visit');

/*
 * AST.
 */

var ast = mdast.parse('Some *emphasis*, **strongness**, and `code`.');

visit(ast, 'text', console.log.bind(console));
/*
 * {type: 'text', 'value': 'Some '}
 * {type: 'text', 'value': 'emphasis'}
 * {type: 'text', 'value': ', '}
 * {type: 'text', 'value': 'strongness'}
 * {type: 'text', 'value': ', and '}
 * {type: 'text', 'value': '.'}
 */

API

visit(ast[, type], callback[, reverse])

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

  • ast (Node) — mdast node;

  • type (string, optional) — Optional node type to invoke callback for. By default, all nodes are visited.

  • callback (function(node, index?, parent?)) — Callback when a node (matching type) is found. Invoked with the node, its index in parent (or null), and its parent (or null).

    Can return false to stop checking.

  • reverse (boolean, default: false, optional) — 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.

License

MIT © Titus Wormer

Keywords

FAQs

Package last updated on 05 Jul 2015

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc