Socket
Book a DemoInstallSign in
Socket

hast-util-is-element

Package Overview
Dependencies
Maintainers
2
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hast-util-is-element

hast utility to check if a node is a (certain) element

latest
Source
npmnpm
Version
3.0.0
Version published
Weekly downloads
3.1M
-18.48%
Maintainers
2
Weekly downloads
 
Created

What is hast-util-is-element?

The hast-util-is-element package is a utility for working with HAST (Hypertext Abstract Syntax Tree) nodes. It provides functions to check if a node is an element and optionally matches a given tag name. This is particularly useful when manipulating or inspecting HTML represented within JavaScript.

What are hast-util-is-element's main functionalities?

Check if a node is an element

This feature allows you to verify if a given node is an element node within a HAST structure. It's useful for filtering or processing nodes in a tree.

const isElement = require('hast-util-is-element');

const node = {type: 'element', tagName: 'div'};
console.log(isElement(node)); // Outputs: true

Check if a node is a specific element

This feature extends the basic check to allow for specification of the tag name. It's useful for finding or working with specific types of elements in a document.

const isElement = require('hast-util-is-element');

const node = {type: 'element', tagName: 'span'};
console.log(isElement(node, 'span')); // Outputs: true

Other packages similar to hast-util-is-element

Keywords

unist

FAQs

Package last updated on 31 Jul 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