npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

domdedom

v1.0.4

Published

Clean, declarative DOM querying using JavaScript Proxies and destructuring assignment.

Readme

domdedom

npm version bundle size npm downloads license

Clean, declarative DOM querying using JavaScript Proxies and destructuring assignment.

Stop writing repetitive document.getElementById and document.querySelector boilerplate. domdedom turns DOM access into native-feeling object destructuring and dynamic function calls—with zero dependencies and no build steps required.


Features

  • Declarative Destructuring: Bind elements directly to variable names (const { submitBtn, userForm } = DOM.id).
  • Dual Invocation: Every accessor supports both object property destructuring and direct functional invocation (DOM.id('btn-' + id)).
  • Zero Dependencies: Native ES6 Proxy forwarding to browser DOM methods.
  • Under 1 KB: Tiny footprint with virtually zero engine overhead.
  • Full TypeScript Support: Shipped with comprehensive .d.ts definitions out of the box.

Installation

npm install domdedom

Or install with Yarn / pnpm:

yarn add domdedom
# or
pnpm add domdedom

Usage

1. Destructuring by ID

Instead of repetitive lookups:

// Traditional boilerplate
const submitBtn = document.getElementById('submitBtn');
const username = document.getElementById('username');
const errorModal = document.getElementById('errorModal');

Write clean, declarative bindings:

import { DOM } from 'domdedom';

const { submitBtn, username, errorModal } = DOM.id;

2. Destructuring Classes, Tags, and Names

Access live DOM collections (HTMLCollection and NodeList) using identical syntax:

// Classes (HTMLCollection)
const { card, badge } = DOM.class;

// Tag names (HTMLCollection)
const { li, p, button } = DOM.tag;

// Name attributes (NodeList)
const { csrfToken } = DOM.name;

3. CSS Selectors with qs and qsa

Query single elements (querySelector) or node lists (querySelectorAll). For selectors with characters like ., #, [, or >, use standard JavaScript destructuring renaming syntax:

// Simple tags map directly
const { body, header } = DOM.qs;

// Complex selectors unpack cleanly via alias renaming
const {
  '.nav-item.active': activeNav,
  'input[type="checkbox"]:checked': checkedBox
} = DOM.qs;

const {
  'ul > li': listItems,
  '.gallery img': galleryImages
} = DOM.qsa;

4. Dual Invocation (Calls + Properties)

Every helper in domdedom wraps a callable function target. That means you get static destructuring upfront and natural function execution in dynamic runtime expressions:

// Static upfront destructuring
const { saveBtn, cancelBtn } = DOM.id;

// Direct dot property access
DOM.id.saveBtn.disabled = true;

// Dynamic expression calls (no computed brackets needed)
const dynamicCard = DOM.id('card-' + index);
const activeItem  = DOM.qs(`.list-item[data-id="${selectedId}"]`);
const buttons     = DOM.tag('button');

API Reference

| Accessor | Native Method Dispatched | Return Type | Description | | :--- | :--- | :--- | :--- | | DOM.id | document.getElementById | HTMLElement \| null | Matches element by id attribute | | DOM.class | document.getElementsByClassName | HTMLCollectionOf<Element> | Live collection matching class name | | DOM.tag | document.getElementsByTagName | HTMLCollectionOf<Element> | Live collection matching tag name | | DOM.name | document.getElementsByName | NodeList | Live collection matching name attribute | | DOM.qs | document.querySelector | Element \| null | First element matching CSS selector | | DOM.qsa | document.querySelectorAll | NodeListOf<Element> | Static list of all matching elements |


Important Considerations

  1. Evaluation Timing: Destructuring executes the query at the exact line of execution. Ensure elements are loaded in the DOM (e.g., after DOMContentLoaded or component mount) before destructuring, otherwise the variables will bind to null or empty collections.
  2. Static vs. Live References:
    • Variables destructured locally store the element reference from that moment:
      const { modal } = DOM.id; // Bound once
    • Direct access or function calls re-query the document every time:
      DOM.id.modal.showModal(); // Re-queried on access
      DOM.id('modal').showModal(); // Re-queried on invocation
  3. Performance: Trap forwarding costs nanoseconds. DOM tree lookups and browser layout passes dominate runtime, so Proxy dispatch overhead is negligible in practice.

TypeScript

TypeScript types are included with no extra @types package required:

import { DOM } from 'domdedom';

// Typed as HTMLElement | null
const { submitBtn } = DOM.id;

// Typed as NodeListOf<Element>
const { 'ul > li': items } = DOM.qsa;

// Fully typed function invocation
const main = DOM.qs('#main');

Browser Support

Works in all modern evergreen browsers (Chrome, Edge, Firefox, Safari) and any environment supporting ES6 Proxies and the standard DOM API.


License

MIT © Evan Pierce