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

@papit/html

v0.0.1

Published

a minimal html parser intended for node that exposes the core set of functionalities regular document DOM exposes

Downloads

206

Readme

@papit/html

A lightweight, deterministic HTML and DOM-like implementation for Node.js.

Logo

This library provides a minimal, predictable subset of the DOM focused on:

  • Server-side HTML generation
  • Tree-based manipulation
  • Deterministic querying
  • Zero browser globals
  • No polyfills or environment magic

It is not a browser DOM and does not aim to be one.

Type Tests NPM version

Features

  • ✅ Zero dependencies
  • ✅ Small footprint
  • ✅ DOM-inspired class hierarchy (Node, Element, Text, Document, Comment)
  • ✅ Tree construction from HTML strings
  • querySelector, querySelectorAll, and closest
  • ✅ Attribute handling via Map
  • classList via a simplified DOMTokenList
  • NodeList / read-only array-like traversal helpers
  • innerHTML / outerHTML serialization
  • ✅ Deterministic, explicit behavior (no hidden browser magic)
  • ✅ Explicit ownership via ownerDocument

Core Concepts

Document as the Node Factory

All nodes should be created via Document.

const doc = new Document();

const el = doc.createElement("div");
const text = doc.createTextNode("Hello");
el.appendChild(text);

⚠️ Nodes are expected to have an owning Document. Constructing nodes manually may lead to missing ownership and broken tree relationships.


Nodes

Node

Base class for all nodes.

Properties:

  • parentNode
  • childNodes
  • textContent
  • nodeType
  • ownerDocument

Node extends EventTarget.


Text

Represents text nodes.

const text = doc.createTextNode("Hello");
  • nodeType === Node.TEXT_NODE
  • textContent always returns a string

Element

Represents HTML elements.

const el = doc.createElement("div", {
  attributes: { id: "main" },
  className: "foo bar",
});

Properties:

  • tagName
  • attributes: Map<string, string | true>
  • className
  • classList
  • children

Methods:

  • appendChild
  • removeChild
  • closest
  • querySelector
  • querySelectorAll

HTMLElement

class HTMLElement<T = string> extends Element {}

HTMLElement<T> currently behaves the same as Element and exists to enable future specialization and typing improvements.


NodeList

childNodes and children return a read-only, array-like NodeList.

Supported methods:

  • forEach
  • entries
  • keys
  • values
  • item(index)

The list itself cannot be mutated, but the nodes inside it can.


classList

classList behaves like a simplified DOMTokenList.

Supported methods:

  • add
  • remove
  • toggle
  • contains

Changes are reflected in className.


HTML Serialization

innerHTML

  • Serializes child nodes
  • Setting it rebuilds the subtree
el.innerHTML = "<span>Hello</span>";

outerHTML

  • Serializes the node including its own tag
  • Produces valid HTML strings

Document.outerHTML serializes the document’s child nodes.


Querying

Limited, deterministic selector support:

  • Tag selectors: div
  • Class selectors: .foo
  • Attribute selectors: [id=main]
  • Text selectors: {Hello}
  • Combined selectors: div.foo[id=bar]{Hello}
  • Descendant and child combinators: , >

The sibling (+) combinator is parsed but currently treated as a descendant. Proper sibling matching may be implemented in a future release.

This is not CSS-complete by design.


Why not jsdom?

@papit/html intentionally solves a different problem.

jsdom

  • Full browser DOM emulation
  • Heavy
  • Environment-dependent
  • Complex edge cases
  • Slow for simple HTML tasks

@papit/html

  • Deterministic

  • Lightweight

  • Explicit tree ownership

  • No browser assumptions

  • Ideal for:

    • Build tools
    • Static HTML generation
    • Controlled DOM manipulation
    • Testing

If you need browser fidelity — use jsdom. If you need control and predictability — use @papit/html.


License

Licensed under the @Papit License 1.0 Copyright (c) 2024 Henry Pap (@onkelhoy)

Summary:

  • ✅ Free for commercial use
  • ✅ Free to modify and distribute
  • ✅ Attribution required
  • ❌ Cannot resell as a standalone product

See the LICENSE file for full details.