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

pdfquery

v0.2.0

Published

```ts import pdfquery from 'pdfquery'

Readme

pdfquery

import pdfquery from 'pdfquery'

const doc = { id: 'doc-2026-04' }
const page = { id: 'page-1', number: 1 }
const annotation = { id: 'annot-7', page: 1 }

const $doc = pdfquery([doc, page, annotation])

$doc.on('change', (event) => {
  console.log('changed node', event.target, event.detail)
})

$doc.on('annotation', (event) => {
  console.log('annotation event', event.target, event.detail)
})

$doc.on('verify', (event) => {
  console.log('verification score', event.detail)
})

$doc.on('load', (event) => {
  console.log('loaded', event.target)
})

pdfquery(page).trigger('change', { field: 'rotation', value: 90 })
pdfquery(annotation).trigger('annotation', { x: 148, y: 320, text: 'check total' })
pdfquery(doc).trigger('verify', { score: 0.98, reasons: ['totals match'] })
pdfquery(doc).trigger('load')

pdfquery is a minimal, tree-agnostic, jQuery-style wrapper for object-shaped PDF nodes. It does not parse PDFs, construct trees, or implement CSS selectors. You bring your own nodes; pdfquery gives you a small collection wrapper and a WeakMap-backed event plane over those nodes.

The mental model: facets push events via .trigger(), consumers subscribe via .on(), and pdfquery is the tree-indexed broker in between.

Install

npm install pdfquery

ESM only. Zero runtime dependencies. Runs in browsers, Node >=18, Cloudflare Workers, Bun, and Deno-compatible ESM environments.

Typed Events

import pdfquery from 'pdfquery'

type PdfEvents = {
  verify: { score: number; reasons: string[] }
  annotation: { x: number; y: number; text: string }
  load: void
}

const nodes = [{ id: 'page-1' }]
const $ = pdfquery<{ id: string }, PdfEvents>(nodes)

$.on('verify', (event) => {
  event.detail.score
  event.target.id
})

$.trigger('verify', { score: 0.91, reasons: ['signature present'] })
$.trigger('load', undefined)

Unknown event names are still allowed and use unknown detail, which keeps pdfquery open to event names created by plugins, parser facets, and application code.

Surface

| API | Description | | --- | --- | | pdfquery(node) | Wrap one object-shaped node. | | pdfquery(nodes) | Wrap an array or iterable of object-shaped nodes. | | pdfquery(wrapper) | Return an existing pdfquery collection. | | .on(type, handler) | Subscribe handlers on each node in the collection. | | .off(type?, handler?) | Remove one handler, all handlers for a type, or all handlers. | | .one(type, handler) | Subscribe a handler that removes itself after one call. | | .trigger(type, detail?) | Synchronously emit an event for each unique node in the collection. | | .each(fn) | Iterate nodes and return the collection. | | .map(fn) | Return a native array of mapped values. | | .filter(fn) | Return a new collection of matching nodes. | | .first() | Return a collection containing the first node, if present. | | .last() | Return a collection containing the last node, if present. | | .eq(i) | Return a collection containing the node at index i, if present. | | .length | Number of nodes in the collection. | | [index] | Indexed access to nodes. | | [Symbol.iterator] | Use for...of, spread, or Array.from. |

Errors

If an event handler throws, pdfquery continues invoking the remaining handlers. It then emits an error event on the same node with:

{ source: 'handler', type, error }

If no error listener is registered anywhere in the triggering collection, the original error is rethrown synchronously.

What pdfquery Does Not Do

pdfquery v0.2 has no selector engine, traversal, mutation, content access, style helpers, ajax, DOM event bridge, or ready callback. See divergence.md for the full jQuery divergence list.

Companion Parser

Tree construction and provider adapters are moving to @okrapdf/doc-parser (WIP). Use that package, or your own parser/index, to produce the object-shaped nodes that pdfquery wraps.

v1 Roadmap

  • Keep the wrapper/event core small and dependency-free.
  • Stabilize interop with @okrapdf/doc-parser.
  • Document common PDF event vocabularies for parser facets, verification facets, annotation facets, and UI layers.
  • Consider optional companion packages for selectors or traversal without adding them to core.

License

MIT