Socket
Socket
Sign inDemoInstall

domutils

Package Overview
Dependencies
1
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    domutils

utilities for working with htmlparser2's dom


Version published
Weekly downloads
39M
increased by2.97%
Maintainers
1
Install size
14.5 kB
Created
Weekly downloads
 

Package description

What is domutils?

The domutils package is a utility library for working with DOM elements in Node.js. It provides a variety of functions to manipulate and traverse the DOM, extract information, and convert between different formats.

What are domutils's main functionalities?

Manipulating the DOM

This feature allows you to manipulate DOM elements by appending children or removing elements.

const { append, removeElement } = require('domutils');
const dom = [{ type: 'tag', name: 'div' }];
const child = { type: 'tag', name: 'span' };
append(dom[0], child);
removeElement(child);

Traversing the DOM

This feature provides functions to traverse the DOM and find elements based on a predicate function.

const { findOne, findAll } = require('domutils');
const dom = [{ type: 'tag', name: 'div', children: [{ type: 'tag', name: 'span' }] }];
const span = findOne(elem => elem.name === 'span', dom);
const allDivs = findAll(elem => elem.name === 'div', dom);

Extracting information

This feature allows you to extract information such as text content from DOM elements.

const { getText } = require('domutils');
const dom = [{ type: 'text', data: 'Hello World' }];
const text = getText(dom);

Converting between formats

This feature enables you to convert DOM elements to other formats, such as HTML strings.

const { getOuterHTML } = require('domutils');
const dom = [{ type: 'tag', name: 'div', children: [{ type: 'text', data: 'Hello World' }] }];
const html = getOuterHTML(dom);

Other packages similar to domutils

Readme

Source

utilities for working with htmlparser2's dom

Keywords

FAQs

Last updated on 10 Nov 2012

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc