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

domutils

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

domutils

Utilities for working with htmlparser2's dom

  • 2.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
15M
decreased by-62.23%
Maintainers
1
Weekly downloads
 
Created

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

Keywords

FAQs

Package last updated on 17 Aug 2020

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