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

nozzle-js

v0.11.0

Published

Chainable stream processing for async iterators. Transform LLM responses, event streams, and more with a fluent API.

Readme

Nozzle is a small TypeScript library for transforming async iterables, especially streamed text from LLMs.

It helps when provider chunks are not the chunks your app wants: parse structured markers, split text into useful pieces, fan out one stream to multiple consumers, extract generated sections, or smooth token timing without waiting for the whole response.

Quickstart

npm i nozzle-js # or pnpm / bun / yarn

Nozzle has ESM and CJS builds and works with any sync or async iterable.

import { nz } from "nozzle-js"

const pacedWords = nz(llmTextStream)
  .splitAfter(" ")
  .compact()
  .minInterval(40)

for await (const word of pacedWords) {
  process.stdout.write(word)
}

Recipes

Parse structured markers as they stream

const stream = await openai.chat.completions.create({ ...args, stream: true })

const parts = nz(stream)
  .map((chunk) => chunk.choices[0]?.delta?.content ?? "")
  .parse(/img-(\w+)/g, (match) => ({ type: "image", id: match[1] }))

// yields: "Here is ", { type: "image", id: "abc123" }, " for you"

Parse Demo

Branch one stream for UI and storage

const [displayStream, storageStream] = nz(stream).tee(2)

const displayPromise = (async () => {
  for await (const chunk of displayStream) process.stdout.write(chunk)
})()

const [, consumed] = await Promise.all([displayPromise, storageStream.consume()])
conversation.push({ role: "assistant", content: consumed.string() })

Tee Demo

Extract a generated section

const code = await nz(stream)
  .after("```ts\n")
  .before("```")
  .tap(sendToPreview)
  .consume()

await saveSnippet(code.string())

Extract Demo

Smooth chunky provider output

const smoothStream = nz(stream)
  .splitAfter(" ")
  .compact()
  .minInterval(40)

Timing Demo

Behavior

  • Pipelines are consumed with for await or .consume(). Generator sources are single-use.
  • .consume() retains all values; use .list(), .string(), or .return() on its result.
  • Early exit closes upstream iterators. Pending I/O needs cancellation from the source/provider.
  • buffer(), tee, and asyncMap can buffer without a limit; concurrency is not a queue limit.
  • Regexes match across chunks. Anchors, word boundaries, lookarounds, backreferences, Unicode escapes (\uXXXX, \u{…}), m/y/v, and nullable patterns are rejected. The explicit empty separator splits UTF-16 code units. Unfinished matches buffer input; match indices are buffer-local.

Reference

{{reference}}

Development

pnpm install --frozen-lockfile
pnpm run check

Run pnpm run docs after editing API comments or this README's template. Run pnpm run release:dry to validate package contents without publishing. The release:patch, release:minor, and release:major scripts publish and push tags.

License

This library is licensed under the MIT license.