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

nwsapi

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nwsapi

Fast CSS Selectors API Engine

  • 2.2.16
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
26M
increased by7.45%
Maintainers
1
Weekly downloads
 
Created

What is nwsapi?

The nwsapi npm package is a modern and efficient CSS selector engine that allows developers to query the DOM using CSS selectors. It is designed to be fast and fully compliant with the most recent CSS specifications.

What are nwsapi's main functionalities?

DOM Selection

This feature allows you to select DOM elements using CSS selectors. The code sample demonstrates how to select all elements with the class 'className' that are direct children of a 'div' element.

const nwsapi = require('nwsapi');
const doc = nwsapi(document);
const elements = doc.querySelectorAll('div > .className');

Matches Selector

This feature checks if a given element matches a specific CSS selector. The code sample demonstrates how to check if the element with the id 'myElement' also has the class 'someClass'.

const nwsapi = require('nwsapi');
const doc = nwsapi(document);
const element = document.getElementById('myElement');
const isMatch = doc.matchesSelector(element, '#myElement.someClass');

Custom Pseudo-classes

This feature allows you to define custom pseudo-classes for more complex queries. The code sample demonstrates how to define a custom pseudo-class that selects elements with a 'data-custom' attribute.

const nwsapi = require('nwsapi');
const doc = nwsapi(document);
doc.definePseudo('custom', function(elem) {
  return elem.hasAttribute('data-custom');
});
const customElements = doc.querySelectorAll(':custom');

Other packages similar to nwsapi

Keywords

FAQs

Package last updated on 29 Nov 2024

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