push-stream-std

@push-stream-std/push-stringify (0.0.8)

Published 2026-07-21 04:01:03 +00:00 by Dvorak

Installation

@push-stream-std:registry=https://hub.kl1.tenere.ai/api/packages/push-stream-std/npm/
npm install @push-stream-std/push-stringify@0.0.8
"@push-stream-std/push-stringify": "0.0.8"

About this package

@push-stream-std/push-stringify

JSON.stringify through stream with array and NDJSON output modes.

Published as @push-stream-std/push-stringify.

Synopsis

import { stringify, array, lines } from '@push-stream-std/push-stringify';

const source = values([{ a: 1 }, { b: 2 }, { c: 3 }]);

source.pipe(stringify()).pipe(log());   // "{\"a\":1}" "{\"b\":2}" "{\"c\":3}"
source.pipe(array()).pipe(log());       // "[{\"a\":1},{\"b\":2},{\"c\":3}]"
source.pipe(lines()).pipe(log());       // "{\"a\":1}\n{\"b\":2}\n{\"c\":3}\n"

Install

npm config set @push-stream-std:registry https://hub.kl1.tenere.ai/api/packages/push-stream-std/npm/
npm config set -- //hub.kl1.tenere.ai/api/packages/push-stream-std/npm/:_authToken "$PACKAGE_TOKEN"
npm install @push-stream-std/push-stringify

Why

A push-stream through that buffers all incoming values and emits the JSON-serialized result on end. Three modes are available: stringify emits each value as a separate JSON string, array emits all values as a single JSON array, and lines emits each value as a line of newline-delimited JSON (NDJSON). All values are buffered in memory until the stream ends.

API

stringify(options)

Creates a through stream that emits each value as an individual JSON string.

  • options object (optional) – Reserved for future use.
  • Returns A through object with pipe(), write(), end(), abort(), resume(), source, sink, paused, ended.

array(options)

Creates a through stream that emits the entire buffer as a single JSON array string on end.

  • options object (optional) – Reserved for future use.
  • Returns A through object.

lines(options)

Creates a through stream that emits each value as a JSON string followed by '\n' (NDJSON format).

  • options object (optional) – Reserved for future use.
  • Returns A through object.

Tests

npm test

Requirements

Node.js 22 or later. ESM only.

Keywords

push-stream stream stringify json ndjson
Details
npm
2026-07-21 04:01:03 +00:00
0
SEE LICENSE IN LICENSE
latest
3.4 KiB
Assets (1)
Versions (5) View all
0.0.8 2026-07-21
0.0.7 2026-07-20
0.0.6 2026-07-20
0.0.5 2026-07-19
0.0.3 2026-07-19