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

hast-util-to-estree

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

hast-util-to-estree

hast utility to transform to estree (JavaScript AST) JSX

  • 3.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.2M
decreased by-21.64%
Maintainers
2
Weekly downloads
 
Created

What is hast-util-to-estree?

The `hast-util-to-estree` package is a utility that converts HAST (Hypertext Abstract Syntax Tree) to ESTree (ECMAScript Tree). This is particularly useful for projects that need to manipulate HTML or Markdown content and then transform it into JavaScript code structures.

What are hast-util-to-estree's main functionalities?

Convert HAST to ESTree

This feature allows you to convert a HAST node into an ESTree node. The code sample demonstrates converting a simple HAST node representing a <div> element into its ESTree equivalent.

const toEstree = require('hast-util-to-estree');
const hast = { type: 'element', tagName: 'div', properties: {}, children: [] };
const estree = toEstree(hast);
console.log(estree);

Handling different HAST node types

This feature shows how the utility handles different types of HAST nodes, including text nodes. The code sample converts a HAST node representing a <p> element with text content into its ESTree equivalent.

const toEstree = require('hast-util-to-estree');
const hast = { type: 'element', tagName: 'p', properties: {}, children: [{ type: 'text', value: 'Hello, world!' }] };
const estree = toEstree(hast);
console.log(estree);

Other packages similar to hast-util-to-estree

Keywords

FAQs

Package last updated on 01 Sep 2023

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