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

@telperion/dom-utils

v1.1.0

Published

DOM utility functions for web development

Readme

@telperion/dom-utils

npm npm codecov TypeScript License: MIT

Lightweight DOM utility helpers for the modern web — tree-shakable, dependency-free, fully typed.

Part of the Telperion monorepo

Installation

npm install @telperion/dom-utils
# or
yarn add @telperion/dom-utils
# or
pnpm add @telperion/dom-utils

Features

  • 🌳 getParents — Lazily walk up the parent chain of any element
  • 🪞 DomClone — Deep-clone an element and keep the clone in sync with subsequent mutations (attributes, child nodes, text, inline styles)
  • 📦 Tree-shakable per-file deep imports (@telperion/dom-utils/get-parents, @telperion/dom-utils/dom-clone)
  • 0️⃣ Zero runtime dependencies (other than tslib)

API

getParents

Lazily yields each ancestor of the given element walking up the parent chain. Stops when there is no further parentElement.

import { getParents } from '@telperion/dom-utils/get-parents';

const node = document.querySelector('.deep-child')!;

for (const parent of getParents(node)) {
  console.log(parent.tagName);
}

Signature

function getParents<T extends HTMLElement = HTMLElement>(node: T): Generator<T>;

Parameters

  • node — The element to start walking from.

Returns

  • A Generator<T> that yields each ancestor element from closest to furthest.

DomClone

Deep-clones a target element and keeps the clone live: any subsequent mutation on the original — attribute changes (including inline style), text / character-data updates, and child node insertions/removals across the whole subtree — is mirrored onto the clone via a single MutationObserver.

Sync is one-way (target → clone). Mutations on the clone are not reflected back.

import { DomClone } from '@telperion/dom-utils/dom-clone';

const target = document.querySelector('#source')!;
const mirror = new DomClone(target);

document.body.appendChild(mirror.clone);

// Any mutation on `target` from now on is reflected on `mirror.clone`:
target.setAttribute('data-state', 'active');
target.style.color = 'tomato';
target.append(document.createElement('span'));

// When you are done:
mirror.disconnect();

Constructor

new DomClone<T extends Element = Element>(target: T, options?: DomCloneOptions);

Options

| Option | Type | Default | Description | | --- | --- | --- | --- | | attributes | boolean | true | Mirror attribute additions/changes/removals (covers inline style). | | childList | boolean | true | Mirror child node insertions and removals across the subtree. | | characterData | boolean | true | Mirror text / character-data changes across the subtree. |

Members

  • readonly clone: T — The deep-cloned, live-synced element. Append it anywhere in the document.
  • disconnect(): void — Stops mirroring further mutations. Safe to call multiple times.

Building

Run pnpm nx run dom-utils:build to build the library.

Running unit tests

Run pnpm nx run dom-utils:test to execute the unit tests via Vitest.

License

MIT