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

dom-pouch

v1.2.1

Published

A pouch of helper methods for dealing with the DOM

Readme

Dom Pouch

Dom Pouch provides a variety of helper methods written in TypeScript for interacting with the DOM and reducing the amount of code needed to perform simple tasks.

Installation

// Yarn
yarn add dom-pouch

// NPM
npm install dom-pouch

Usage

Just import the methods you need

import { findFirst } from 'dom-pouch';

Methods

Selectors

find(selector: stering, context: Document | Element = document): Element[]

Returns an array of all elements which match the selector string.

findFirst(selector: string, context: Document | Element = document): Element

Returns the first element which matches the selector string.


Attributes

getAttr(element: Element, attribute: string): string | null

Returns the value of an attribute for the element.

setAttr(element: Element, attribute: string, value: string): void

Sets the value of an attribute for the element.

setDataAttr(element: HTMLElement | SVGElement, attribute: string, value: string): void

Sets the value of a data attribute for the element.

getDataAttr(element: HTMLElement | SVGElement, attribute: string): string | null

Returns the value of a data attribute for the element.

toggleAttrVal(element: Element, attribute: string, valueOne: string, valueTwo: string): void

Toggles an attribute between two values for the element.


Events

listen<T extends HTMLElement>(elements: T | T[], events: string | string[], callback: (element: T, event: Event) => void): void

Simple way of binding multiple events to multiple elements. Both elements and events accept either a single item or an array of items. The callback method passes the element as the first argument followed by the event object. By defualt, the passed element in the callback has the type of HTMLElement, but this can be changed by passing a type variable, e.g...

listen<HTMLFormElement>(forms, 'submit', (form, event) => {
    // The form argument is of type HTMLFormElement
});

createEvent(eventName: string): Event

Creates a new event which is compatible with IE11


Traversing

removeElement(element: Element): void

Removes an element from the DOM

insertAfter(elementToInsert: Element, referenceElement: Element): void

Inserts an element after the reference element

insertBefore(elementToInsert: Element, referenceElement: Element): void

Inserts an element before the reference element

prependElement(elementToInsert: Element, parentElement: Element): void

Add's an element to the beginning of the parent element

appendElement(elementToInsert: Element, parentElement: Element): void

Add's an element to the end of the parent element