Socket
Socket
Sign inDemoInstall

unist-util-map

Package Overview
Dependencies
Maintainers
2
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unist-util-map

Create a new Unist tree with all nodes that mapped by the provided function


Version published
Weekly downloads
96K
increased by25.62%
Maintainers
2
Weekly downloads
 
Created

What is unist-util-map?

The unist-util-map package is a utility for transforming unist syntax trees by applying a function to each node, creating a new tree with the same structure but with transformed nodes.

What are unist-util-map's main functionalities?

Transforming Nodes

This feature allows you to apply a transformation function to each node in a unist tree. In the example, each text node's value is transformed to uppercase.

const map = require('unist-util-map');

const tree = {
  type: 'root',
  children: [
    { type: 'text', value: 'Hello' },
    { type: 'text', value: 'World' }
  ]
};

const newTree = map(tree, node => {
  if (node.type === 'text') {
    return { ...node, value: node.value.toUpperCase() };
  }
  return node;
});

console.log(newTree);

Other packages similar to unist-util-map

Keywords

FAQs

Package last updated on 21 May 2019

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