Socket
Socket
Sign inDemoInstall

unist-util-visit-parents

Package Overview
Dependencies
Maintainers
2
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unist-util-visit-parents

unist utility to recursively walk over nodes, with ancestral information


Version published
Weekly downloads
15M
decreased by-2.37%
Maintainers
2
Weekly downloads
 
Created

What is unist-util-visit-parents?

The unist-util-visit-parents package is a utility for traversing Unist syntax trees. It allows for visiting nodes, optionally filtered by type, and provides access to parent nodes during traversal. This can be particularly useful for manipulating or inspecting the structure of documents parsed into Unist syntax trees, such as Markdown or HTML parsed by remark or rehype processors.

What are unist-util-visit-parents's main functionalities?

Visiting nodes with access to their parents

This feature allows you to visit all nodes of a specified type ('paragraph' in this example) in a Unist syntax tree, and for each node, you have access to an array of its ancestor nodes. This is useful for context-aware processing or transformations.

visit(tree, 'paragraph', (node, ancestors) => {
  console.log(node);
  console.log(ancestors);
});

Visiting all nodes without filtering

This feature enables visiting all nodes in the syntax tree without filtering by type. Each visited node is accompanied by its ancestors, allowing for comprehensive traversal and manipulation of the tree.

visit(tree, (node, ancestors) => {
  console.log(node);
  console.log(ancestors);
});

Other packages similar to unist-util-visit-parents

Keywords

FAQs

Package last updated on 10 May 2021

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