Socket
Socket
Sign inDemoInstall

domutils

Package Overview
Dependencies
4
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
Maintainers
1
Weekly downloads
37,037,286
decreased by-7.99%

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

domutils Node.js CI

Utilities for working with htmlparser2's DOM.

All functions are exported as a single module. Look through the docs to see what is available.

Ecosystem

NameDescription
htmlparser2Fast & forgiving HTML/XML parser
domhandlerHandler for htmlparser2 that turns documents into a DOM
domutilsUtilities for working with domhandler's DOM
css-selectCSS selector engine, compatible with domhandler's DOM
cheerioThe jQuery API for domhandler's DOM
dom-serializerSerializer for domhandler's DOM

License: BSD-2-Clause

Security contact information

To report a security vulnerability, please use the Tidelift security contact. Tidelift will coordinate the fix and disclosure.

domutils for enterprise

Available as part of the Tidelift Subscription

The maintainers of domutils and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.

Keywords

FAQs

Last updated on 29 Apr 2023

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