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

@withremyinc/stream

v1.0.3

Published

Composable Web Streams utilities with streaming JSON and XML parsing.

Readme

@withremyinc/stream

CI npm package License: MIT

Composable helpers for the Web Streams API, plus incremental JSON and XML parsers for text and AI pipelines.

  • ESM-only
  • Node 18+
  • Web Streams-native APIs
  • Small functional helpers for ReadableStream / TransformStream
  • Tolerant streaming parsers for JSONC-style JSON and XML fragments

Installation

npm install @withremyinc/stream
pnpm add @withremyinc/stream
yarn add @withremyinc/stream

Quick start

import { arrayStream, collect, filter, map } from "@withremyinc/stream";

const output = await collect(
  arrayStream([1, 2, 3, 4])
    .pipeThrough(map((value) => value * 2))
    .pipeThrough(filter((value) => value > 4)),
);

console.log(output); // [6, 8]

What is included?

Stream helpers

Sources / composition

  • arrayStream()
  • merge()
  • mergeKeyed()
  • concat()
  • pipeThrough()
  • tee()

pipeThrough() composes multiple TransformStreams into a single transform when you want to pass around a whole pipeline.

Collectors

  • collect()
  • collectFirst()
  • collectLast()
  • collectToString()

Transforms

  • map()
  • filter()
  • filterMap()
  • flatMap()
  • scan()
  • reduce()
  • take()
  • takeLast()
  • drop()
  • toArray()
  • toString()
  • forEach()
  • some()
  • every()
  • find()
  • extractDelimiter()

Streaming JSON

parseJSON() tokenizes and parses JSON incrementally and emits visit events. jsonToJSObject() folds those events back into a plain JavaScript value.

It is intentionally tolerant of JSONC-style input such as comments and trailing commas. When parsing LLM/tool-call streams, pass { emitPartialStrings: true } to emit onPartialLiteralValue events for open string literals at chunk boundaries.

import {
  arrayStream,
  collect,
  jsonToJSObject,
  parseJSON,
  takeLast,
} from "@withremyinc/stream";

const [value] = await collect(
  arrayStream(['{ "name": "Remy", /* comment */ }'])
    .pipeThrough(parseJSON())
    .pipeThrough(jsonToJSObject())
    .pipeThrough(takeLast(1)),
);

console.log(value); // { name: "Remy" }
import { arrayStream, collect, parseJSON } from "@withremyinc/stream";

const events = await collect(
  arrayStream(['{"name":"str', 'eam"}']).pipeThrough(
    parseJSON({ emitPartialStrings: true }),
  ),
);

console.log(events);
// includes { type: "onPartialLiteralValue", value: "str", path: ["name"] }

Streaming XML

parseXML() incrementally parses XML documents or fragments and emits events such as:

  • onDocumentBegin
  • onElementBegin
  • onText
  • onElementEnd
  • onError

It is non-validating and recovery-oriented, which makes it useful for LLM output and other imperfect text streams.

import { arrayStream, collect, parseXML } from "@withremyinc/stream";

const events = await collect(
  arrayStream(["<root><item>Hello</item></root>"]).pipeThrough(parseXML()),
);

console.log(events);

If you only want specific top-level XML islands from mixed text, use extractXML():

import { arrayStream, collect, extractXML } from "@withremyinc/stream";

const events = await collect(
  arrayStream([
    'before <answer confidence="0.9">hello</answer> after',
  ]).pipeThrough(extractXML({ allowTags: ["answer"] })),
);

Delimited block extraction

extractDelimiter() streams the body of the first matching fenced block and drops the fence lines. This is handy for extracting Markdown code fences before passing the contents into parseJSON() or parseXML().

import {
  arrayStream,
  collectToString,
  extractDelimiter,
} from "@withremyinc/stream";

const body = await collectToString(
  arrayStream([
    "ignore this\n```json\n",
    '{"ok": true}\n',
    "```\ntrailing text",
  ]).pipeThrough(extractDelimiter({ allowLanguages: ["json"] })),
);

console.log(body); // {"ok": true}\n

Development

Published output targets Node 18+, but local builds currently require Node 20.19+ because tsdown does. .nvmrc and .node-version are included for that toolchain.

pnpm install
pnpm test
pnpm typecheck
pnpm build

Extra scripts:

  • pnpm bench:geojson
  • pnpm bench:xml

Changelog

See CHANGELOG.md.

Releasing

For the full checklist, see RELEASING.md.

Quick version:

  1. Bump the package version with pnpm version patch (or minor / major).
  2. Push the commit and matching tag with git push --follow-tags.
  3. GitHub Actions publishes that tag to npm.

The publish workflow expects an NPM_TOKEN repository secret and uses npm provenance.

Release notes / packaging

This package publishes the built dist/ output plus:

  • README.md
  • CHANGELOG.md
  • LICENSE.md
  • NOTICES.md

License

MIT.

Copyright © 2026 Remy, Inc.

See LICENSE.md for the project license and NOTICES.md for bundled third-party notices.