Socket
Socket
Sign inDemoInstall

nwmatcher

Package Overview
Dependencies
0
Maintainers
2
Versions
16
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    nwmatcher

A CSS3-compliant JavaScript selector engine.


Version published
Weekly downloads
424K
decreased by-19.64%
Maintainers
2
Install size
136 kB
Created
Weekly downloads
 

Package description

What is nwmatcher?

The nwmatcher npm package is a fast CSS selector engine and matcher, primarily used for matching DOM elements against CSS selectors. It is useful for tasks such as querying and filtering elements in a DOM-like structure.

What are nwmatcher's main functionalities?

Matching Elements

This feature allows you to check if a given DOM element matches a specific CSS selector.

const NWMatcher = require('nwmatcher');
const matcher = NWMatcher({ document });
const element = document.getElementById('example');
const isMatch = matcher.match(element, '.example-class');
console.log(isMatch); // true or false

Querying Elements

This feature allows you to query and retrieve all DOM elements that match a specific CSS selector.

const NWMatcher = require('nwmatcher');
const matcher = NWMatcher({ document });
const elements = matcher.select('.example-class');
console.log(elements); // Array of elements matching the selector

Custom Selectors

This feature allows you to register and use custom selectors for more advanced querying.

const NWMatcher = require('nwmatcher');
const matcher = NWMatcher({ document });
matcher.registerSelector('custom', function(element) {
  return element.hasAttribute('data-custom');
});
const elements = matcher.select(':custom');
console.log(elements); // Array of elements with the 'data-custom' attribute

Other packages similar to nwmatcher

Readme

Source

Keywords

FAQs

Last updated on 11 Feb 2013

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc