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

snapdragon-util

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

snapdragon-util

Utilities for the snapdragon parser/compiler.

  • 5.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9.8M
decreased by-20.89%
Maintainers
1
Weekly downloads
 
Created

What is snapdragon-util?

The snapdragon-util npm package provides utility functions for working with AST (Abstract Syntax Tree) nodes, which are commonly used in parsers and compilers. It offers a set of tools to manipulate, visit, and manage AST nodes effectively.

What are snapdragon-util's main functionalities?

Visit Nodes

This feature allows you to visit each node in an AST. The provided code sample demonstrates how to traverse an AST and log the type of each node.

const util = require('snapdragon-util');
const ast = { type: 'root', nodes: [{ type: 'text', value: 'Hello' }, { type: 'text', value: 'World' }] };
util.visit(ast, node => console.log(node.type));

Map Nodes

This feature allows you to map over each node in an AST and transform it. The provided code sample demonstrates how to convert the text values of nodes to uppercase.

const util = require('snapdragon-util');
const ast = { type: 'root', nodes: [{ type: 'text', value: 'Hello' }, { type: 'text', value: 'World' }] };
const newAst = util.map(ast, node => {
  if (node.type === 'text') {
    node.value = node.value.toUpperCase();
  }
  return node;
});
console.log(newAst);

Filter Nodes

This feature allows you to filter nodes in an AST based on a condition. The provided code sample demonstrates how to filter nodes that have a value of 'Hello'.

const util = require('snapdragon-util');
const ast = { type: 'root', nodes: [{ type: 'text', value: 'Hello' }, { type: 'text', value: 'World' }] };
const filteredNodes = util.filter(ast, node => node.value === 'Hello');
console.log(filteredNodes);

Other packages similar to snapdragon-util

Keywords

FAQs

Package last updated on 11 Jan 2018

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