New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

basic-devtools

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

basic-devtools

Exports `$`, `$$`, and `$x` utilities as described in Chrome Console Utilities API reference

  • 0.1.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
16K
decreased by-11.14%
Maintainers
1
Weekly downloads
 
Created
Source

basic-devtools

Coverage Status build status

Social Media Photo by Basic Moto France on Unsplash

Exports $, $$, and $x utilities as described in Chrome Console Utilities API reference, all in 242 bytes once "minzipped" or 206 bytes once "minbrotlied".

import {$, $$, $x} from 'basic-devtools';

// single node
$('nope') === null;                 // true
$('body') === document.body;        // true

// list of nodes
$$('body').length === 1;            // true
$$('body')[0] === document.body;    // true

// list of evaluated nodes
$x('//body').length === 1;          // true
$x('//body')[0] === document.body;  // true

What's the deal with XPath?

It's extremely powerful but also generally faster than a TreeWalker, as you can test live.

As example, let's consider this Question:

"How would I grab all data-* attributes and reach their element with a single-pass query?"

Answer

// grab all nodes with data-* attributes
const allDataAttributes = $x('//@*[starts-with(name(), "data-")]');

// loop all returned attributes and do something
for (const {name, value, ownerElement} of allDataAttributes) {
  // ownerElement is the element using data-* attribute
  // name is the data-* attribute name
  // value is its value
}

You can have a gist of various other features via this awesome Xpath cheatsheet.

Keywords

FAQs

Package last updated on 26 Apr 2023

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