@datastream/core
Advanced tools
+98
| // Copyright 2026 will Farrell, and datastream contributors. | ||
| // SPDX-License-Identifier: MIT | ||
| // Core types used across all packages | ||
| export interface StreamOptions { | ||
| highWaterMark?: number; | ||
| chunkSize?: number; | ||
| signal?: AbortSignal; | ||
| [key: string]: unknown; | ||
| } | ||
| export interface StreamResult<T = unknown> { | ||
| key: string; | ||
| value: T; | ||
| } | ||
| export interface ResultStream<_S, T = unknown> { | ||
| result: () => StreamResult<T> | Promise<StreamResult<T>>; | ||
| } | ||
| // Pipeline & utilities | ||
| export function pipeline( | ||
| streams: unknown[], | ||
| streamOptions?: StreamOptions, | ||
| ): Promise<Record<string, unknown>>; | ||
| export function pipejoin( | ||
| streams: unknown[], | ||
| onError?: (error: Error) => void, | ||
| ): unknown; | ||
| export function result(streams: unknown[]): Promise<Record<string, unknown>>; | ||
| // Stream converters | ||
| export function streamToArray<T = unknown>(stream: unknown): Promise<T[]>; | ||
| export function streamToObject<T = Record<string, unknown>>( | ||
| stream: unknown, | ||
| ): Promise<T>; | ||
| export function streamToString(stream: unknown): Promise<string>; | ||
| export function streamToBuffer(stream: unknown): Promise<Buffer>; | ||
| // Type guards | ||
| export function isReadable(stream: unknown): stream is ReadableStream; | ||
| export function isWritable(stream: unknown): stream is WritableStream; | ||
| // Options helper | ||
| export function makeOptions(options?: StreamOptions): Record<string, unknown>; | ||
| // Stream creators | ||
| export function createReadableStream<T = unknown>( | ||
| input?: string | T[] | Iterable<T> | AsyncIterable<T>, | ||
| streamOptions?: StreamOptions, | ||
| ): unknown; | ||
| export function createReadableStreamFromString( | ||
| input: string, | ||
| streamOptions?: StreamOptions, | ||
| ): unknown; | ||
| export function createReadableStreamFromArrayBuffer( | ||
| input: ArrayBuffer | ArrayBufferLike, | ||
| streamOptions?: StreamOptions, | ||
| ): unknown; | ||
| export function createPassThroughStream<T = unknown>( | ||
| passThrough?: ((chunk: T) => void | Promise<void>) | null, | ||
| flush?: (() => void | Promise<void>) | StreamOptions, | ||
| streamOptions?: StreamOptions, | ||
| ): unknown & ResultStream<unknown>; | ||
| export function createTransformStream<I = unknown, O = unknown>( | ||
| transform?: | ||
| | (( | ||
| chunk: I, | ||
| enqueue: (chunk: O, encoding?: string) => void, | ||
| ) => void | Promise<void>) | ||
| | null, | ||
| flush?: | ||
| | ((enqueue: (chunk: O, encoding?: string) => void) => void | Promise<void>) | ||
| | StreamOptions, | ||
| streamOptions?: StreamOptions, | ||
| ): unknown; | ||
| export function createWritableStream<T = unknown>( | ||
| write?: ((chunk: T) => void | Promise<void>) | null, | ||
| close?: (() => void | Promise<void>) | StreamOptions, | ||
| streamOptions?: StreamOptions, | ||
| ): unknown; | ||
| // Backpressure (Node.js only) | ||
| export function backpressureGauge(streams: Record<string, unknown>): Record< | ||
| string, | ||
| { | ||
| timeline: Array<{ timestamp: number; duration: number }>; | ||
| total: { timestamp?: number; duration?: number }; | ||
| } | ||
| >; | ||
| // Timeout | ||
| export function timeout( | ||
| ms: number, | ||
| options?: { signal?: AbortSignal }, | ||
| ): Promise<void>; |
+52
| <div align="center"> | ||
| <h1><datastream> `core`</h1> | ||
| <img alt="datastream logo" src="https://raw.githubusercontent.com/willfarrell/datastream/main/docs/img/datastream-logo.svg"/> | ||
| <p><strong>Core component of the datastream framework, the robust JavaScript streaming utility.</strong></p> | ||
| <p> | ||
| <a href="https://github.com/willfarrell/datastream/actions/workflows/test-unit.yml"><img src="https://github.com/willfarrell/datastream/actions/workflows/test-unit.yml/badge.svg" alt="GitHub Actions unit test status"></a> | ||
| <a href="https://github.com/willfarrell/datastream/actions/workflows/test-dast.yml"><img src="https://github.com/willfarrell/datastream/actions/workflows/test-dast.yml/badge.svg" alt="GitHub Actions dast test status"></a> | ||
| <a href="https://github.com/willfarrell/datastream/actions/workflows/test-perf.yml"><img src="https://github.com/willfarrell/datastream/actions/workflows/test-perf.yml/badge.svg" alt="GitHub Actions perf test status"></a> | ||
| <a href="https://github.com/willfarrell/datastream/actions/workflows/test-sast.yml"><img src="https://github.com/willfarrell/datastream/actions/workflows/test-sast.yml/badge.svg" alt="GitHub Actions SAST test status"></a> | ||
| <a href="https://github.com/willfarrell/datastream/actions/workflows/test-lint.yml"><img src="https://github.com/willfarrell/datastream/actions/workflows/test-lint.yml/badge.svg" alt="GitHub Actions lint test status"></a> | ||
| <br/> | ||
| <a href="https://www.npmjs.com/package/@datastream/core"><img alt="npm version" src="https://img.shields.io/npm/v/@datastream/core.svg"></a> | ||
| <a href="https://packagephobia.com/result?p=@datastream/core"><img src="https://packagephobia.com/badge?p=@datastream/core" alt="npm install size"></a> | ||
| <a href="https://www.npmjs.com/package/@datastream/core"> | ||
| <img alt="npm weekly downloads" src="https://img.shields.io/npm/dw/@datastream/core.svg"></a> | ||
| <a href="https://www.npmjs.com/package/@datastream/core#provenance"> | ||
| <img alt="npm provenance" src="https://img.shields.io/badge/provenance-Yes-brightgreen"></a> | ||
| <br/> | ||
| <a href="https://scorecard.dev/viewer/?uri=github.com/willfarrell/datastream"><img src="https://api.scorecard.dev/projects/github.com/willfarrell/datastream/badge" alt="Open Source Security Foundation (OpenSSF) Scorecard"></a> | ||
| <a href="https://slsa.dev"><img src="https://slsa.dev/images/gh-badge-level3.svg" alt="SLSA 3"></a> | ||
| <a href="https://github.com/willfarrell/datastream/blob/main/docs/CODE_OF_CONDUCT.md"><img src="https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg"></a> | ||
| <a href="https://biomejs.dev"><img alt="Checked with Biome" src="https://img.shields.io/badge/Checked_with-Biome-60a5fa?style=flat&logo=biome"></a> | ||
| <a href="https://conventionalcommits.org"><img alt="Conventional Commits" src="https://img.shields.io/badge/Conventional%20Commits-1.0.0-%23FE5196?logo=conventionalcommits&logoColor=white"></a> | ||
| <a href="https://github.com/willfarrell/datastream/blob/main/package.json#L32"> | ||
| <img alt="code coverage" src="https://img.shields.io/badge/code%20coverage-95%25-brightgreen"></a> | ||
| </p> | ||
| <p>You can read the documentation at: <a href="https://datastream.js.org">https://datastream.js.org</a></p> | ||
| </div> | ||
| ## Install | ||
| To install datastream you can use NPM: | ||
| ```bash | ||
| npm install --save @datastream/core | ||
| ``` | ||
| ## Documentation and examples | ||
| For documentation and examples, refer to the main [datastream monorepo on GitHub](https://github.com/willfarrell/datastream) or [datastream official website](https://datastream.js.org). | ||
| ## Contributing | ||
| Everyone is very welcome to contribute to this repository. Feel free to [raise issues](https://github.com/willfarrell/datastream/issues) or to [submit Pull Requests](https://github.com/willfarrell/datastream/pulls). | ||
| ## License | ||
| Licensed under [MIT License](LICENSE). Copyright (c) 2026 [will Farrell](https://github.com/willfarrell), and [datastream contributors](https://github.com/willfarrell/datastream/graphs/contributors). |
+138
-51
@@ -42,3 +42,3 @@ import { Readable, Transform, Writable } from "node:stream"; | ||
| }; | ||
| const backpressureGuage = (streams) => { | ||
| const backpressureGauge = (streams) => { | ||
| const keys = Object.keys(streams); | ||
@@ -70,35 +70,91 @@ const values = Object.values(streams); | ||
| }; | ||
| const streamToArray = async (stream) => { | ||
| const value = []; | ||
| for await (const chunk of stream) { | ||
| value.push(chunk); | ||
| const streamToArray = (stream) => { | ||
| if (typeof stream.on === "function") { | ||
| return new Promise((resolve, reject) => { | ||
| const value = []; | ||
| stream.on("data", (chunk) => { | ||
| value.push(chunk); | ||
| }); | ||
| stream.on("end", () => { | ||
| resolve(value); | ||
| }); | ||
| stream.on("error", reject); | ||
| }); | ||
| } | ||
| return value; | ||
| return (async () => { | ||
| const value = []; | ||
| for await (const chunk of stream) { | ||
| value.push(chunk); | ||
| } | ||
| return value; | ||
| })(); | ||
| }; | ||
| const streamToObject = async (stream) => { | ||
| const value = {}; | ||
| for await (const chunk of stream) { | ||
| Object.assign(value, chunk); | ||
| const streamToObject = (stream) => { | ||
| if (typeof stream.on === "function") { | ||
| return new Promise((resolve, reject) => { | ||
| const value = {}; | ||
| stream.on("data", (chunk) => { | ||
| Object.assign(value, chunk); | ||
| }); | ||
| stream.on("end", () => { | ||
| resolve(value); | ||
| }); | ||
| stream.on("error", reject); | ||
| }); | ||
| } | ||
| return value; | ||
| return (async () => { | ||
| const value = {}; | ||
| for await (const chunk of stream) { | ||
| Object.assign(value, chunk); | ||
| } | ||
| return value; | ||
| })(); | ||
| }; | ||
| const streamToString = async (stream) => { | ||
| let value = ""; | ||
| for await (const chunk of stream) { | ||
| value += chunk; | ||
| const streamToString = (stream) => { | ||
| if (typeof stream.on === "function") { | ||
| return new Promise((resolve, reject) => { | ||
| let value = ""; | ||
| stream.on("data", (chunk) => { | ||
| value += chunk; | ||
| }); | ||
| stream.on("end", () => { | ||
| resolve(value); | ||
| }); | ||
| stream.on("error", reject); | ||
| }); | ||
| } | ||
| return value; | ||
| return (async () => { | ||
| let value = ""; | ||
| for await (const chunk of stream) { | ||
| value += chunk; | ||
| } | ||
| return value; | ||
| })(); | ||
| }; | ||
| const streamToBuffer = async (stream) => { | ||
| const value = []; | ||
| for await (const chunk of stream) { | ||
| value.push(Buffer.from(chunk)); | ||
| const streamToBuffer = (stream) => { | ||
| if (typeof stream.on === "function") { | ||
| return new Promise((resolve, reject) => { | ||
| const value = []; | ||
| stream.on("data", (chunk) => { | ||
| value.push(Buffer.from(chunk)); | ||
| }); | ||
| stream.on("end", () => { | ||
| resolve(Buffer.concat(value)); | ||
| }); | ||
| stream.on("error", reject); | ||
| }); | ||
| } | ||
| return Buffer.concat(value); | ||
| return (async () => { | ||
| const value = []; | ||
| for await (const chunk of stream) { | ||
| value.push(Buffer.from(chunk)); | ||
| } | ||
| return Buffer.concat(value); | ||
| })(); | ||
| }; | ||
| const isReadable = (stream) => { | ||
| return !!stream._readableState; | ||
| return stream instanceof Readable; | ||
| }; | ||
| const isWritable = (stream) => { | ||
| return !!stream._writableState; | ||
| return stream instanceof Writable; | ||
| }; | ||
@@ -168,7 +224,14 @@ const makeOptions = ({ | ||
| ...makeOptions(streamOptions), | ||
| async transform(chunk, _encoding, callback) { | ||
| transform(chunk, _encoding, callback) { | ||
| try { | ||
| await passThrough(chunk); | ||
| this.push(chunk); | ||
| callback(); | ||
| const result2 = passThrough(chunk); | ||
| if (result2 != null && typeof result2.then === "function") { | ||
| result2.then(() => { | ||
| this.push(chunk); | ||
| callback(); | ||
| }, callback); | ||
| } else { | ||
| this.push(chunk); | ||
| callback(); | ||
| } | ||
| } catch (e) { | ||
@@ -178,8 +241,14 @@ callback(e); | ||
| }, | ||
| async flush(callback) { | ||
| flush(callback) { | ||
| try { | ||
| if (flush) { | ||
| await flush(); | ||
| const result2 = flush(); | ||
| if (result2 != null && typeof result2.then === "function") { | ||
| result2.then(() => callback(), callback); | ||
| } else { | ||
| callback(); | ||
| } | ||
| } else { | ||
| callback(); | ||
| } | ||
| callback(); | ||
| } catch (e) { | ||
@@ -192,3 +261,3 @@ callback(e); | ||
| const createTransformStream = (transform, flush, streamOptions) => { | ||
| transform ??= (chunk, enqueue) => enqueue(chunk); | ||
| transform ??= (chunk, enqueue2) => enqueue2(chunk); | ||
| if (typeof flush !== "function") { | ||
@@ -198,11 +267,12 @@ streamOptions = flush; | ||
| } | ||
| return new Transform({ | ||
| const stream = new Transform({ | ||
| ...makeOptions(streamOptions), | ||
| async transform(chunk, _encoding, callback) { | ||
| const enqueue = (chunk2, encoding) => { | ||
| this.push(chunk2, encoding); | ||
| }; | ||
| transform(chunk, _encoding, callback) { | ||
| try { | ||
| await transform(chunk, enqueue); | ||
| callback(); | ||
| const result2 = transform(chunk, enqueue); | ||
| if (result2 != null && typeof result2.then === "function") { | ||
| result2.then(() => callback(), callback); | ||
| } else { | ||
| callback(); | ||
| } | ||
| } catch (e) { | ||
@@ -212,11 +282,14 @@ callback(e); | ||
| }, | ||
| async flush(callback) { | ||
| flush(callback) { | ||
| try { | ||
| if (flush) { | ||
| const enqueue = (chunk, encoding) => { | ||
| this.push(chunk, encoding); | ||
| }; | ||
| await flush(enqueue); | ||
| const result2 = flush(enqueue); | ||
| if (result2 != null && typeof result2.then === "function") { | ||
| result2.then(() => callback(), callback); | ||
| } else { | ||
| callback(); | ||
| } | ||
| } else { | ||
| callback(); | ||
| } | ||
| callback(); | ||
| } catch (e) { | ||
@@ -227,2 +300,6 @@ callback(e); | ||
| }); | ||
| const enqueue = (chunk, encoding) => { | ||
| stream.push(chunk, encoding); | ||
| }; | ||
| return stream; | ||
| }; | ||
@@ -238,6 +315,10 @@ const createWritableStream = (write, final, streamOptions) => { | ||
| ...makeOptions(streamOptions), | ||
| async write(chunk, _encoding, callback) { | ||
| write(chunk, _encoding, callback) { | ||
| try { | ||
| await write(chunk); | ||
| callback(); | ||
| const result2 = write(chunk); | ||
| if (result2 != null && typeof result2.then === "function") { | ||
| result2.then(() => callback(), callback); | ||
| } else { | ||
| callback(); | ||
| } | ||
| } catch (e) { | ||
@@ -247,8 +328,14 @@ callback(e); | ||
| }, | ||
| async final(callback) { | ||
| final(callback) { | ||
| try { | ||
| if (final) { | ||
| await final(); | ||
| const result2 = final(); | ||
| if (result2 != null && typeof result2.then === "function") { | ||
| result2.then(() => callback(), callback); | ||
| } else { | ||
| callback(); | ||
| } | ||
| } else { | ||
| callback(); | ||
| } | ||
| callback(); | ||
| } catch (e) { | ||
@@ -264,3 +351,3 @@ callback(e); | ||
| export { | ||
| backpressureGuage, | ||
| backpressureGauge, | ||
| createPassThroughStream, | ||
@@ -267,0 +354,0 @@ createReadableStream, |
| { | ||
| "version": 3, | ||
| "sources": ["index.node.js"], | ||
| "sourcesContent": ["import { Readable, Transform, Writable } from \"node:stream\";\nimport { pipeline as pipelinePromise } from \"node:stream/promises\";\nimport { setTimeout } from \"node:timers/promises\";\n\nexport const pipeline = async (streams, streamOptions = {}) => {\n\tfor (let idx = 0, l = streams.length; idx < l; idx++) {\n\t\tif (typeof streams[idx].then === \"function\") {\n\t\t\tthrow new Error(`Promise instead of stream passed in at index ${idx}`);\n\t\t}\n\t}\n\t// Ensure stream ends with only writable\n\tconst lastStream = streams[streams.length - 1];\n\tif (isReadable(lastStream)) {\n\t\tstreamOptions.objectMode = lastStream._readableState.objectMode;\n\t\tstreams.push(createWritableStream(() => {}, streamOptions));\n\t}\n\tawait pipelinePromise(streams, streamOptions);\n\treturn result(streams);\n};\n\nexport const pipejoin = (\n\tstreams,\n\tonError = (e) => {\n\t\tthrow e;\n\t},\n) => {\n\tconst pipeline = streams.reduce((pipeline, stream, idx) => {\n\t\tif (typeof stream.then === \"function\") {\n\t\t\tthrow new Error(`Promise instead of stream passed in at index ${idx}`);\n\t\t}\n\t\treturn pipeline.pipe(stream).on(\"error\", onError);\n\t});\n\treturn pipeline;\n};\n\nexport const result = async (streams) => {\n\tconst output = {};\n\tfor (const stream of streams) {\n\t\tif (typeof stream.result === \"function\") {\n\t\t\tconst { key, value } = await stream.result();\n\t\t\tif (key) {\n\t\t\t\toutput[key] = value;\n\t\t\t}\n\t\t}\n\t}\n\treturn output;\n};\n\n// Not possible in WebStream\nexport const backpressureGuage = (streams) => {\n\tconst keys = Object.keys(streams);\n\tconst values = Object.values(streams);\n\tconst metrics = {};\n\tfor (let i = 0, l = values.length; i < l; i++) {\n\t\tconst value = values[i];\n\t\tmetrics[keys[i]] = { timeline: [], total: {} };\n\t\tlet timestamp;\n\t\tlet startTimestamp;\n\t\tvalue.on(\"pause\", () => {\n\t\t\ttimestamp = Date.now(); // process.hrtime.bigint()\n\t\t});\n\t\tvalue.on(\"resume\", () => {\n\t\t\tif (timestamp) {\n\t\t\t\t// Number.parseInt( (process.hrtime.bigint() - pauseTimestamp).toString() , 10 ) / 1_000_000 // ms\n\t\t\t\tconst duration = Date.now() - timestamp;\n\t\t\t\tmetrics[keys[i]].timeline.push({ timestamp, duration });\n\t\t\t} else {\n\t\t\t\tstartTimestamp = Date.now();\n\t\t\t}\n\t\t});\n\t\tvalue.on(\"end\", () => {\n\t\t\tconst duration = Date.now() - startTimestamp;\n\t\t\tmetrics[keys[i]].total = { timestamp: startTimestamp, duration };\n\t\t});\n\t}\n\treturn metrics;\n};\n\nexport const streamToArray = async (stream) => {\n\tconst value = [];\n\tfor await (const chunk of stream) {\n\t\tvalue.push(chunk);\n\t}\n\treturn value;\n};\n\nexport const streamToObject = async (stream) => {\n\tconst value = {};\n\tfor await (const chunk of stream) {\n\t\tObject.assign(value, chunk);\n\t}\n\treturn value;\n};\n\nexport const streamToString = async (stream) => {\n\tlet value = \"\";\n\tfor await (const chunk of stream) {\n\t\tvalue += chunk;\n\t}\n\treturn value;\n};\n\nexport const streamToBuffer = async (stream) => {\n\tconst value = [];\n\tfor await (const chunk of stream) {\n\t\tvalue.push(Buffer.from(chunk));\n\t}\n\treturn Buffer.concat(value);\n};\n\nexport const isReadable = (stream) => {\n\treturn !!stream._readableState;\n};\n\nexport const isWritable = (stream) => {\n\treturn !!stream._writableState;\n};\n\nexport const makeOptions = ({\n\thighWaterMark,\n\tchunkSize,\n\tobjectMode,\n\tsignal,\n\t...streamOptions\n} = {}) => {\n\tobjectMode ??= true;\n\treturn {\n\t\twritableHighWaterMark: highWaterMark,\n\t\twritableObjectMode: objectMode,\n\t\treadableObjectMode: objectMode,\n\t\treadableHighWaterMark: highWaterMark,\n\t\thighWaterMark,\n\t\tchunkSize,\n\t\tobjectMode,\n\t\tsignal,\n\t\t...streamOptions,\n\t};\n};\n\nexport const createReadableStream = (input = \"\", streamOptions = {}) => {\n\t// string doesn't chunk, and is slow\n\tif (typeof input === \"string\") {\n\t\treturn createReadableStreamFromString(input, streamOptions);\n\t}\n\tif (typeof input === \"object\" && input.byteLength) {\n\t\treturn createReadableStreamFromArrayBuffer(input, streamOptions);\n\t}\n\treturn Readable.from(input, streamOptions);\n};\n\nexport const createReadableStreamFromString = (input, streamOptions = {}) => {\n\tfunction* iterator(input) {\n\t\tconst size = streamOptions?.chunkSize ?? 16 * 1024;\n\t\tlet position = 0;\n\t\tconst length = input.length;\n\t\twhile (position < length) {\n\t\t\tyield input.substring(position, position + size);\n\t\t\tposition += size;\n\t\t}\n\t}\n\treturn Readable.from(iterator(input), streamOptions);\n};\n\nexport const createReadableStreamFromArrayBuffer = (\n\tinput,\n\tstreamOptions = {},\n) => {\n\tfunction* iterator(input) {\n\t\tconst size = streamOptions?.chunkSize ?? 16 * 1024;\n\t\tconst bytes = new Uint8Array(input);\n\t\tlet position = 0;\n\t\tconst length = bytes.byteLength;\n\t\twhile (position < length) {\n\t\t\tconst nextPosition = position + size;\n\t\t\tyield bytes.subarray(position, nextPosition);\n\t\t\tposition += size;\n\t\t}\n\t}\n\treturn Readable.from(iterator(input), streamOptions);\n};\n\nexport const createPassThroughStream = (passThrough, flush, streamOptions) => {\n\tpassThrough ??= (chunk) => chunk;\n\tif (typeof flush !== \"function\") {\n\t\tstreamOptions = flush;\n\t\tflush = undefined;\n\t}\n\treturn new Transform({\n\t\t...makeOptions(streamOptions),\n\t\tasync transform(chunk, _encoding, callback) {\n\t\t\ttry {\n\t\t\t\tawait passThrough(chunk);\n\t\t\t\tthis.push(chunk);\n\t\t\t\tcallback();\n\t\t\t} catch (e) {\n\t\t\t\tcallback(e);\n\t\t\t}\n\t\t},\n\t\tasync flush(callback) {\n\t\t\ttry {\n\t\t\t\tif (flush) {\n\t\t\t\t\tawait flush();\n\t\t\t\t}\n\t\t\t\tcallback();\n\t\t\t} catch (e) {\n\t\t\t\tcallback(e);\n\t\t\t}\n\t\t},\n\t});\n};\n\nexport const createTransformStream = (transform, flush, streamOptions) => {\n\ttransform ??= (chunk, enqueue) => enqueue(chunk);\n\tif (typeof flush !== \"function\") {\n\t\tstreamOptions = flush;\n\t\tflush = undefined;\n\t}\n\treturn new Transform({\n\t\t...makeOptions(streamOptions),\n\t\tasync transform(chunk, _encoding, callback) {\n\t\t\tconst enqueue = (chunk, encoding) => {\n\t\t\t\tthis.push(chunk, encoding);\n\t\t\t};\n\t\t\ttry {\n\t\t\t\tawait transform(chunk, enqueue);\n\t\t\t\tcallback();\n\t\t\t} catch (e) {\n\t\t\t\tcallback(e);\n\t\t\t}\n\t\t},\n\t\tasync flush(callback) {\n\t\t\ttry {\n\t\t\t\tif (flush) {\n\t\t\t\t\tconst enqueue = (chunk, encoding) => {\n\t\t\t\t\t\tthis.push(chunk, encoding);\n\t\t\t\t\t};\n\t\t\t\t\tawait flush(enqueue);\n\t\t\t\t}\n\t\t\t\tcallback();\n\t\t\t} catch (e) {\n\t\t\t\tcallback(e);\n\t\t\t}\n\t\t},\n\t});\n};\n\nexport const createWritableStream = (write, final, streamOptions) => {\n\twrite ??= () => {};\n\tif (typeof final !== \"function\") {\n\t\tstreamOptions = final;\n\t\tfinal = undefined;\n\t}\n\treturn new Writable({\n\t\t...makeOptions(streamOptions),\n\t\tasync write(chunk, _encoding, callback) {\n\t\t\ttry {\n\t\t\t\tawait write(chunk);\n\t\t\t\tcallback();\n\t\t\t} catch (e) {\n\t\t\t\tcallback(e);\n\t\t\t}\n\t\t},\n\t\tasync final(callback) {\n\t\t\ttry {\n\t\t\t\tif (final) {\n\t\t\t\t\tawait final();\n\t\t\t\t}\n\t\t\t\tcallback();\n\t\t\t} catch (e) {\n\t\t\t\tcallback(e);\n\t\t\t}\n\t\t},\n\t});\n};\n\n/*\nexport const createBranchStream = (\n\t{ streams, resultKey } = {},\n\tstreamOptions = {},\n) => {\n\t// TODO refactor, not good enough\n\t// https://streams.spec.whatwg.org/#rs-model\n\tconst branchStream = createReadableStream(undefined, streamOptions);\n\tconst passThrough = (chunk) => {\n\t\tbranchStream.push(chunk);\n\t};\n\tconst flush = () => {\n\t\tbranchStream.push(null);\n\t};\n\tconst stream = createPassThroughStream(passThrough, flush, streamOptions);\n\n\tstreams.unshift(branchStream);\n\tconst value = pipeline(streams, streamOptions);\n\tstream.result = async () => {\n\t\treturn {\n\t\t\tkey: resultKey ?? \"branch\",\n\t\t\tvalue, // await causes: Promise resolution is still pending but the event loop has already resolved\n\t\t};\n\t};\n\treturn stream;\n};\n*/\n\nexport const timeout = (ms, { signal } = {}) => {\n\treturn setTimeout(ms, { signal });\n};\n"], | ||
| "mappings": "AAAA,SAAS,UAAU,WAAW,gBAAgB;AAC9C,SAAS,YAAY,uBAAuB;AAC5C,SAAS,kBAAkB;AAEpB,MAAM,WAAW,OAAO,S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;AAAA,UAC1B;AACA,gBAAM,MAAM,OAAO;AAAA,QACpB;AACA,iBAAS;AAAA,MACV,SAAS,GAAG;AACX,iBAAS,CAAC;AAAA,MACX;AAAA,IACD;AAAA,EACD,CAAC;AACF;AAEO,MAAM,uBAAuB,CAAC,OAAO,OAAO,kBAAkB;AACpE,YAAU,MAAM;AAAA,EAAC;AACjB,MAAI,OAAO,UAAU,YAAY;AAChC,oBAAgB;AAChB,YAAQ;AAAA,EACT;AACA,SAAO,IAAI,SAAS;AAAA,IACnB,GAAG,YAAY,aAAa;AAAA,IAC5B,MAAM,MAAM,OAAO,WAAW,UAAU;AACvC,UAAI;AACH,cAAM,MAAM,KAAK;AACjB,iBAAS;AAAA,MACV,SAAS,GAAG;AACX,iBAAS,CAAC;AAAA,MACX;AAAA,IACD;AAAA,IACA,MAAM,MAAM,UAAU;AACrB,UAAI;AACH,YAAI,OAAO;AACV,gBAAM,MAAM;AAAA,QACb;AACA,iBAAS;AAAA,MACV,SAAS,GAAG;AACX,iBAAS,CAAC;AAAA,MACX;AAAA,IACD;AAAA,EACD,CAAC;AACF;AA8BO,MAAM,UAAU,CAAC,IAAI,EAAE,OAAO,IAAI,CAAC,MAAM;AAC/C,SAAO,WAAW,IAAI,EAAE,OAAO,CAAC;AACjC;", | ||
| "names": ["pipeline", "input", "chunk"] | ||
| "sourcesContent": ["// Copyright 2026 will Farrell, and datastream contributors.\n// SPDX-License-Identifier: MIT\nimport { Readable, Transform, Writable } from \"node:stream\";\nimport { pipeline as pipelinePromise } from \"node:stream/promises\";\nimport { setTimeout } from \"node:timers/promises\";\n\nexport const pipeline = async (streams, streamOptions = {}) => {\n\tfor (let idx = 0, l = streams.length; idx < l; idx++) {\n\t\tif (typeof streams[idx].then === \"function\") {\n\t\t\tthrow new Error(`Promise instead of stream passed in at index ${idx}`);\n\t\t}\n\t}\n\t// Ensure stream ends with only writable\n\tconst lastStream = streams[streams.length - 1];\n\tif (isReadable(lastStream)) {\n\t\tstreamOptions.objectMode = lastStream._readableState.objectMode;\n\t\tstreams.push(createWritableStream(() => {}, streamOptions));\n\t}\n\tawait pipelinePromise(streams, streamOptions);\n\treturn result(streams);\n};\n\nexport const pipejoin = (\n\tstreams,\n\tonError = (e) => {\n\t\tthrow e;\n\t},\n) => {\n\tconst pipeline = streams.reduce((pipeline, stream, idx) => {\n\t\tif (typeof stream.then === \"function\") {\n\t\t\tthrow new Error(`Promise instead of stream passed in at index ${idx}`);\n\t\t}\n\t\treturn pipeline.pipe(stream).on(\"error\", onError);\n\t});\n\treturn pipeline;\n};\n\nexport const result = async (streams) => {\n\tconst output = {};\n\tfor (const stream of streams) {\n\t\tif (typeof stream.result === \"function\") {\n\t\t\tconst { key, value } = await stream.result();\n\t\t\tif (key) {\n\t\t\t\toutput[key] = value;\n\t\t\t}\n\t\t}\n\t}\n\treturn output;\n};\n\n// Not possible in WebStream\nexport const backpressureGauge = (streams) => {\n\tconst keys = Object.keys(streams);\n\tconst values = Object.values(streams);\n\tconst metrics = {};\n\tfor (let i = 0, l = values.length; i < l; i++) {\n\t\tconst value = values[i];\n\t\tmetrics[keys[i]] = { timeline: [], total: {} };\n\t\tlet timestamp;\n\t\tlet startTimestamp;\n\t\tvalue.on(\"pause\", () => {\n\t\t\ttimestamp = Date.now(); // process.hrtime.bigint()\n\t\t});\n\t\tvalue.on(\"resume\", () => {\n\t\t\tif (timestamp) {\n\t\t\t\t// Number.parseInt( (process.hrtime.bigint() - pauseTimestamp).toString() , 10 ) / 1_000_000 // ms\n\t\t\t\tconst duration = Date.now() - timestamp;\n\t\t\t\tmetrics[keys[i]].timeline.push({ timestamp, duration });\n\t\t\t} else {\n\t\t\t\tstartTimestamp = Date.now();\n\t\t\t}\n\t\t});\n\t\tvalue.on(\"end\", () => {\n\t\t\tconst duration = Date.now() - startTimestamp;\n\t\t\tmetrics[keys[i]].total = { timestamp: startTimestamp, duration };\n\t\t});\n\t}\n\treturn metrics;\n};\n\nexport const streamToArray = (stream) => {\n\tif (typeof stream.on === \"function\") {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst value = [];\n\t\t\tstream.on(\"data\", (chunk) => {\n\t\t\t\tvalue.push(chunk);\n\t\t\t});\n\t\t\tstream.on(\"end\", () => {\n\t\t\t\tresolve(value);\n\t\t\t});\n\t\t\tstream.on(\"error\", reject);\n\t\t});\n\t}\n\treturn (async () => {\n\t\tconst value = [];\n\t\tfor await (const chunk of stream) {\n\t\t\tvalue.push(chunk);\n\t\t}\n\t\treturn value;\n\t})();\n};\n\nexport const streamToObject = (stream) => {\n\tif (typeof stream.on === \"function\") {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst value = {};\n\t\t\tstream.on(\"data\", (chunk) => {\n\t\t\t\tObject.assign(value, chunk);\n\t\t\t});\n\t\t\tstream.on(\"end\", () => {\n\t\t\t\tresolve(value);\n\t\t\t});\n\t\t\tstream.on(\"error\", reject);\n\t\t});\n\t}\n\treturn (async () => {\n\t\tconst value = {};\n\t\tfor await (const chunk of stream) {\n\t\t\tObject.assign(value, chunk);\n\t\t}\n\t\treturn value;\n\t})();\n};\n\nexport const streamToString = (stream) => {\n\tif (typeof stream.on === \"function\") {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tlet value = \"\";\n\t\t\tstream.on(\"data\", (chunk) => {\n\t\t\t\tvalue += chunk;\n\t\t\t});\n\t\t\tstream.on(\"end\", () => {\n\t\t\t\tresolve(value);\n\t\t\t});\n\t\t\tstream.on(\"error\", reject);\n\t\t});\n\t}\n\treturn (async () => {\n\t\tlet value = \"\";\n\t\tfor await (const chunk of stream) {\n\t\t\tvalue += chunk;\n\t\t}\n\t\treturn value;\n\t})();\n};\n\nexport const streamToBuffer = (stream) => {\n\tif (typeof stream.on === \"function\") {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst value = [];\n\t\t\tstream.on(\"data\", (chunk) => {\n\t\t\t\tvalue.push(Buffer.from(chunk));\n\t\t\t});\n\t\t\tstream.on(\"end\", () => {\n\t\t\t\tresolve(Buffer.concat(value));\n\t\t\t});\n\t\t\tstream.on(\"error\", reject);\n\t\t});\n\t}\n\treturn (async () => {\n\t\tconst value = [];\n\t\tfor await (const chunk of stream) {\n\t\t\tvalue.push(Buffer.from(chunk));\n\t\t}\n\t\treturn Buffer.concat(value);\n\t})();\n};\n\nexport const isReadable = (stream) => {\n\treturn stream instanceof Readable;\n};\n\nexport const isWritable = (stream) => {\n\treturn stream instanceof Writable;\n};\n\nexport const makeOptions = ({\n\thighWaterMark,\n\tchunkSize,\n\tobjectMode,\n\tsignal,\n\t...streamOptions\n} = {}) => {\n\tobjectMode ??= true;\n\treturn {\n\t\twritableHighWaterMark: highWaterMark,\n\t\twritableObjectMode: objectMode,\n\t\treadableObjectMode: objectMode,\n\t\treadableHighWaterMark: highWaterMark,\n\t\thighWaterMark,\n\t\tchunkSize,\n\t\tobjectMode,\n\t\tsignal,\n\t\t...streamOptions,\n\t};\n};\n\nexport const createReadableStream = (input = \"\", streamOptions = {}) => {\n\t// string doesn't chunk, and is slow\n\tif (typeof input === \"string\") {\n\t\treturn createReadableStreamFromString(input, streamOptions);\n\t}\n\tif (typeof input === \"object\" && input.byteLength) {\n\t\treturn createReadableStreamFromArrayBuffer(input, streamOptions);\n\t}\n\treturn Readable.from(input, streamOptions);\n};\n\nexport const createReadableStreamFromString = (input, streamOptions = {}) => {\n\tfunction* iterator(input) {\n\t\tconst size = streamOptions?.chunkSize ?? 16 * 1024;\n\t\tlet position = 0;\n\t\tconst length = input.length;\n\t\twhile (position < length) {\n\t\t\tyield input.substring(position, position + size);\n\t\t\tposition += size;\n\t\t}\n\t}\n\treturn Readable.from(iterator(input), streamOptions);\n};\n\nexport const createReadableStreamFromArrayBuffer = (\n\tinput,\n\tstreamOptions = {},\n) => {\n\tfunction* iterator(input) {\n\t\tconst size = streamOptions?.chunkSize ?? 16 * 1024;\n\t\tconst bytes = new Uint8Array(input);\n\t\tlet position = 0;\n\t\tconst length = bytes.byteLength;\n\t\twhile (position < length) {\n\t\t\tconst nextPosition = position + size;\n\t\t\tyield bytes.subarray(position, nextPosition);\n\t\t\tposition += size;\n\t\t}\n\t}\n\treturn Readable.from(iterator(input), streamOptions);\n};\n\nexport const createPassThroughStream = (passThrough, flush, streamOptions) => {\n\tpassThrough ??= (chunk) => chunk;\n\tif (typeof flush !== \"function\") {\n\t\tstreamOptions = flush;\n\t\tflush = undefined;\n\t}\n\treturn new Transform({\n\t\t...makeOptions(streamOptions),\n\t\ttransform(chunk, _encoding, callback) {\n\t\t\ttry {\n\t\t\t\tconst result = passThrough(chunk);\n\t\t\t\tif (result != null && typeof result.then === \"function\") {\n\t\t\t\t\tresult.then(() => {\n\t\t\t\t\t\tthis.push(chunk);\n\t\t\t\t\t\tcallback();\n\t\t\t\t\t}, callback);\n\t\t\t\t} else {\n\t\t\t\t\tthis.push(chunk);\n\t\t\t\t\tcallback();\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\tcallback(e);\n\t\t\t}\n\t\t},\n\t\tflush(callback) {\n\t\t\ttry {\n\t\t\t\tif (flush) {\n\t\t\t\t\tconst result = flush();\n\t\t\t\t\tif (result != null && typeof result.then === \"function\") {\n\t\t\t\t\t\tresult.then(() => callback(), callback);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcallback();\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tcallback();\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\tcallback(e);\n\t\t\t}\n\t\t},\n\t});\n};\n\nexport const createTransformStream = (transform, flush, streamOptions) => {\n\ttransform ??= (chunk, enqueue) => enqueue(chunk);\n\tif (typeof flush !== \"function\") {\n\t\tstreamOptions = flush;\n\t\tflush = undefined;\n\t}\n\tconst stream = new Transform({\n\t\t...makeOptions(streamOptions),\n\t\ttransform(chunk, _encoding, callback) {\n\t\t\ttry {\n\t\t\t\tconst result = transform(chunk, enqueue);\n\t\t\t\tif (result != null && typeof result.then === \"function\") {\n\t\t\t\t\tresult.then(() => callback(), callback);\n\t\t\t\t} else {\n\t\t\t\t\tcallback();\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\tcallback(e);\n\t\t\t}\n\t\t},\n\t\tflush(callback) {\n\t\t\ttry {\n\t\t\t\tif (flush) {\n\t\t\t\t\tconst result = flush(enqueue);\n\t\t\t\t\tif (result != null && typeof result.then === \"function\") {\n\t\t\t\t\t\tresult.then(() => callback(), callback);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcallback();\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tcallback();\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\tcallback(e);\n\t\t\t}\n\t\t},\n\t});\n\tconst enqueue = (chunk, encoding) => {\n\t\tstream.push(chunk, encoding);\n\t};\n\treturn stream;\n};\n\nexport const createWritableStream = (write, final, streamOptions) => {\n\twrite ??= () => {};\n\tif (typeof final !== \"function\") {\n\t\tstreamOptions = final;\n\t\tfinal = undefined;\n\t}\n\treturn new Writable({\n\t\t...makeOptions(streamOptions),\n\t\twrite(chunk, _encoding, callback) {\n\t\t\ttry {\n\t\t\t\tconst result = write(chunk);\n\t\t\t\tif (result != null && typeof result.then === \"function\") {\n\t\t\t\t\tresult.then(() => callback(), callback);\n\t\t\t\t} else {\n\t\t\t\t\tcallback();\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\tcallback(e);\n\t\t\t}\n\t\t},\n\t\tfinal(callback) {\n\t\t\ttry {\n\t\t\t\tif (final) {\n\t\t\t\t\tconst result = final();\n\t\t\t\t\tif (result != null && typeof result.then === \"function\") {\n\t\t\t\t\t\tresult.then(() => callback(), callback);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcallback();\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tcallback();\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\tcallback(e);\n\t\t\t}\n\t\t},\n\t});\n};\n\nexport const timeout = (ms, { signal } = {}) => {\n\treturn setTimeout(ms, { signal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ACjC,UAAI;AACH,cAAMA,UAAS,MAAM,KAAK;AAC1B,YAAIA,WAAU,QAAQ,OAAOA,QAAO,SAAS,YAAY;AACxD,UAAAA,QAAO,KAAK,MAAM,SAAS,GAAG,QAAQ;AAAA,QACvC,OAAO;AACN,mBAAS;AAAA,QACV;AAAA,MACD,SAAS,GAAG;AACX,iBAAS,CAAC;AAAA,MACX;AAAA,IACD;AAAA,IACA,MAAM,UAAU;AACf,UAAI;AACH,YAAI,OAAO;AACV,gBAAMA,UAAS,MAAM;AACrB,cAAIA,WAAU,QAAQ,OAAOA,QAAO,SAAS,YAAY;AACxD,YAAAA,QAAO,KAAK,MAAM,SAAS,GAAG,QAAQ;AAAA,UACvC,OAAO;AACN,qBAAS;AAAA,UACV;AAAA,QACD,OAAO;AACN,mBAAS;AAAA,QACV;AAAA,MACD,SAAS,GAAG;AACX,iBAAS,CAAC;AAAA,MACX;AAAA,IACD;AAAA,EACD,CAAC;AACF;AAEO,MAAM,UAAU,CAAC,IAAI,EAAE,OAAO,IAAI,CAAC,MAAM;AAC/C,SAAO,WAAW,IAAI,EAAE,OAAO,CAAC;AACjC;", | ||
| "names": ["pipeline", "input", "result", "enqueue"] | ||
| } |
+2
-2
@@ -56,6 +56,6 @@ const pipeline = async (streams, streamOptions = {}) => { | ||
| const isReadable = (stream) => { | ||
| return typeof stream.pipeTo === "function" || !!stream.readable; | ||
| return stream instanceof ReadableStream || !!stream.readable; | ||
| }; | ||
| const isWritable = (stream) => { | ||
| return typeof stream.pipeTo === "undefined" || !!stream.writable; | ||
| return stream instanceof WritableStream || !!stream.writable; | ||
| }; | ||
@@ -62,0 +62,0 @@ const makeOptions = ({ |
| { | ||
| "version": 3, | ||
| "sources": ["index.web.js"], | ||
| "sourcesContent": ["/* global ReadableStream, TransformStream, WritableStream */\n\nexport const pipeline = async (streams, streamOptions = {}) => {\n\t// Ensure stream ends with only writable\n\tconst lastStream = streams[streams.length - 1];\n\tif (isReadable(lastStream)) {\n\t\tstreams.push(createWritableStream(() => {}, streamOptions));\n\t}\n\n\tawait pipejoin(streams);\n\treturn result(streams);\n};\n\nexport const pipejoin = (streams) => {\n\tconst lastIndex = streams.length - 1;\n\treturn streams.reduce((pipeline, stream, idx) => {\n\t\tif (typeof stream.then === \"function\") {\n\t\t\tthrow new Error(`Promise instead of stream passed in at index ${idx}`);\n\t\t}\n\t\tif (idx === lastIndex && stream.getWriter) {\n\t\t\treturn pipeline.pipeTo(stream);\n\t\t}\n\t\treturn pipeline.pipeThrough(stream);\n\t});\n};\n\nexport const result = async (streams) => {\n\tconst output = {};\n\tfor (const stream of streams) {\n\t\tif (typeof stream.result === \"function\") {\n\t\t\tconst { key, value } = await stream.result();\n\t\t\tif (key) {\n\t\t\t\toutput[key] = value;\n\t\t\t}\n\t\t}\n\t}\n\treturn output;\n};\n\nexport const streamToArray = async (stream) => {\n\tconst value = [];\n\tfor await (const chunk of stream) {\n\t\tvalue.push(chunk);\n\t}\n\treturn value;\n};\n\nexport const streamToObject = async (stream) => {\n\tconst value = {};\n\tfor await (const chunk of stream) {\n\t\tObject.assign(value, chunk);\n\t}\n\treturn value;\n};\n\nexport const streamToString = async (stream) => {\n\tlet value = \"\";\n\tfor await (const chunk of stream) {\n\t\tvalue += chunk;\n\t}\n\treturn value;\n};\n\n/* export const streamToBuffer = async (stream) => {\n let byteLength = 0\n let value = []\n for await (const chunk of stream) {\n byteLength += chunk.length\n value.push([new Uint8Array(chunk),byteLength])\n }\n return value.reduce((buffer, set) => {\n if (!buffer) buffer = new Uint8Array(byteLength)\n buffer.set(...set)\n return buffer\n })\n} */\n\nexport const isReadable = (stream) => {\n\treturn typeof stream.pipeTo === \"function\" || !!stream.readable; // TODO find better solution\n};\n\nexport const isWritable = (stream) => {\n\treturn typeof stream.pipeTo === \"undefined\" || !!stream.writable; // TODO find better solution\n};\n\nexport const makeOptions = ({\n\thighWaterMark,\n\tchunkSize,\n\tsignal,\n\t...streamOptions\n} = {}) => {\n\treturn {\n\t\twritableStrategy: {\n\t\t\thighWaterMark,\n\t\t\tsize: { chunk: chunkSize },\n\t\t},\n\t\treadableStrategy: {\n\t\t\thighWaterMark,\n\t\t\tsize: { chunk: chunkSize },\n\t\t},\n\t\tsignal,\n\t\t...streamOptions,\n\t};\n};\n\nexport const createReadableStream = (input, streamOptions = {}) => {\n\tconst queued = [];\n\tconst stream = new ReadableStream(\n\t\t{\n\t\t\tasync start(controller) {\n\t\t\t\twhile (queued.length) {\n\t\t\t\t\tconst chunk = queued.shift();\n\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t}\n\t\t\t\tif (typeof input === \"string\") {\n\t\t\t\t\tconst chunkSize = streamOptions?.chunkSize ?? 16 * 1024;\n\t\t\t\t\tlet position = 0;\n\t\t\t\t\tconst length = input.length;\n\t\t\t\t\twhile (position < length) {\n\t\t\t\t\t\tconst chunk = input.substring(position, position + chunkSize);\n\t\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\t\tposition += chunkSize;\n\t\t\t\t\t}\n\t\t\t\t\tcontroller.close();\n\t\t\t\t} else if (Array.isArray(input)) {\n\t\t\t\t\t// TODO update to for(;;) loop, faster\n\t\t\t\t\tfor (const chunk of input) {\n\t\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\t}\n\t\t\t\t\tcontroller.close();\n\t\t\t\t} else if ([\"function\", \"object\"].includes(typeof input)) {\n\t\t\t\t\tfor await (const chunk of input) {\n\t\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\t}\n\t\t\t\t\tcontroller.close();\n\t\t\t\t}\n\t\t\t},\n\t\t\tpull(controller) {\n\t\t\t\twhile (queued.length) {\n\t\t\t\t\tconst chunk = queued.shift();\n\t\t\t\t\tif (chunk === null) {\n\t\t\t\t\t\tcontroller.close();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\tmakeOptions(streamOptions),\n\t);\n\tstream.push = (chunk) => queued.push(chunk);\n\treturn stream;\n};\n\nexport const createPassThroughStream = (passThrough, flush, streamOptions) => {\n\tpassThrough ??= (_chunk) => {};\n\tif (typeof flush !== \"function\") {\n\t\tstreamOptions = flush;\n\t\tflush = undefined;\n\t}\n\treturn new TransformStream(\n\t\t{\n\t\t\tstart() {},\n\t\t\tasync transform(chunk, controller) {\n\t\t\t\tawait passThrough(chunk);\n\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t},\n\t\t\tasync flush(controller) {\n\t\t\t\tif (flush) {\n\t\t\t\t\tawait flush();\n\t\t\t\t}\n\t\t\t\tcontroller.terminate();\n\t\t\t},\n\t\t},\n\t\tmakeOptions(streamOptions),\n\t);\n};\n\nexport const createTransformStream = (transform, flush, streamOptions) => {\n\ttransform ??= (chunk, enqueue) => enqueue(chunk);\n\tif (typeof flush !== \"function\") {\n\t\tstreamOptions = flush;\n\t\tflush = undefined;\n\t}\n\treturn new TransformStream(\n\t\t{\n\t\t\tstart() {},\n\t\t\tasync transform(chunk, controller) {\n\t\t\t\tconst enqueue = (chunk, encoding) => {\n\t\t\t\t\tcontroller.enqueue(chunk, encoding);\n\t\t\t\t};\n\t\t\t\tawait transform(chunk, enqueue);\n\t\t\t},\n\t\t\tasync flush(controller) {\n\t\t\t\tif (flush) {\n\t\t\t\t\tconst enqueue = (chunk, encoding) => {\n\t\t\t\t\t\tcontroller.enqueue(chunk, encoding);\n\t\t\t\t\t};\n\t\t\t\t\tawait flush(enqueue);\n\t\t\t\t}\n\t\t\t\tcontroller.terminate();\n\t\t\t},\n\t\t},\n\t\tmakeOptions(streamOptions),\n\t);\n};\n\nexport const createWritableStream = (write, close, streamOptions) => {\n\twrite ??= () => {};\n\tif (typeof close !== \"function\") {\n\t\tstreamOptions = close;\n\t\tclose = undefined;\n\t}\n\treturn new WritableStream(\n\t\t{\n\t\t\tasync write(chunk) {\n\t\t\t\tawait write(chunk);\n\t\t\t},\n\t\t\tasync close() {\n\t\t\t\tif (close) {\n\t\t\t\t\tawait close();\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\tmakeOptions(streamOptions),\n\t);\n};\n\n/*\nexport const createBranchStream = (\n\t{ streams, resultKey } = {},\n\tstreamOptions = {},\n) => {\n\t// TODO refactor, not good enough\n\t// https://streams.spec.whatwg.org/#rs-model\n\tconst branchStream = createReadableStream(undefined, streamOptions);\n\tconst passThrough = (chunk) => {\n\t\tbranchStream.push(chunk);\n\t};\n\tconst flush = () => {\n\t\tbranchStream.push(null);\n\t};\n\tconst stream = createPassThroughStream(passThrough, flush, streamOptions);\n\n\tstreams.unshift(branchStream);\n\tconst value = pipeline(streams, streamOptions);\n\tstream.result = async () => {\n\t\treturn {\n\t\t\tkey: resultKey ?? \"branch\",\n\t\t\tvalue, // await causes: Promise resolution is still pending but the event loop has already resolved\n\t\t};\n\t};\n\treturn stream;\n};\n*/\n\n/* export const tee = (sourceStream) => {\n return sourceStream.tee()\n} */\n\n// Polyfill for `import { setTimeout } from 'node:timers/promises'`\nexport const timeout = (ms, { signal } = {}) => {\n\tif (signal?.aborted) {\n\t\treturn Promise.reject(new Error(\"Aborted\", \"AbortError\"));\n\t}\n\treturn new Promise((resolve, reject) => {\n\t\tconst abortHandler = () => {\n\t\t\tclearTimeout(timeout);\n\t\t\treject(new Error(\"Aborted\", \"AbortError\"));\n\t\t};\n\t\tif (signal) signal.addEventListener(\"abort\", abortHandler);\n\t\tsetTimeout(() => {\n\t\t\tresolve();\n\t\t\tif (signal) signal.removeEventListener(\"abort\", abortHandler);\n\t\t}, ms);\n\t});\n};\n"], | ||
| "mappings": "AAEO,MAAM,WAAW,OAAO,SAAS,gBAAgB,CAAC,MAAM;AAE9D,QAAM,aAAa,QAAQ,QAAQ,SAAS,CAAC;AAC7C,MAAI,WAAW,UAAU,GAAG;AAC3B,YAAQ,KAAK,qBAAqB,MAAM;AAAA,IAAC,GAAG,aAAa,CAAC;AAAA,EAC3D;AAEA,QAAM,SAAS,OAAO;AACtB,SAAO,OAAO,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AAA,EAC1B;AACD;AAEO,MAAM,uBAAuB,CAAC,OAAO,OAAO,kBAAkB;AACpE,YAAU,MAAM;AAAA,EAAC;AACjB,MAAI,OAAO,UAAU,YAAY;AAChC,oBAAgB;AAChB,YAAQ;AAAA,EACT;AACA,SAAO,IAAI;AAAA,IACV;AAAA,MACC,MAAM,MAAM,OAAO;AAClB,cAAM,MAAM,KAAK;AAAA,MAClB;AAAA,MACA,MAAM,QAAQ;AACb,YAAI,OAAO;AACV,gBAAM,MAAM;AAAA,QACb;AAAA,MACD;AAAA,IACD;AAAA,IACA,YAAY,aAAa;AAAA,EAC1B;AACD;AAmCO,MAAM,UAAU,CAAC,IAAI,EAAE,OAAO,IAAI,CAAC,MAAM;AAC/C,MAAI,QAAQ,SAAS;AACpB,WAAO,QAAQ,OAAO,IAAI,MAAM,WAAW,YAAY,CAAC;AAAA,EACzD;AACA,SAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACvC,UAAM,eAAe,MAAM;AAC1B,mBAAa,OAAO;AACpB,aAAO,IAAI,MAAM,WAAW,YAAY,CAAC;AAAA,IAC1C;AACA,QAAI,OAAQ,QAAO,iBAAiB,SAAS,YAAY;AACzD,eAAW,MAAM;AAChB,cAAQ;AACR,UAAI,OAAQ,QAAO,oBAAoB,SAAS,YAAY;AAAA,IAC7D,GAAG,EAAE;AAAA,EACN,CAAC;AACF;", | ||
| "sourcesContent": ["// Copyright 2026 will Farrell, and datastream contributors.\n// SPDX-License-Identifier: MIT\n/* global ReadableStream, TransformStream, WritableStream */\n\nexport const pipeline = async (streams, streamOptions = {}) => {\n\t// Ensure stream ends with only writable\n\tconst lastStream = streams[streams.length - 1];\n\tif (isReadable(lastStream)) {\n\t\tstreams.push(createWritableStream(() => {}, streamOptions));\n\t}\n\n\tawait pipejoin(streams);\n\treturn result(streams);\n};\n\nexport const pipejoin = (streams) => {\n\tconst lastIndex = streams.length - 1;\n\treturn streams.reduce((pipeline, stream, idx) => {\n\t\tif (typeof stream.then === \"function\") {\n\t\t\tthrow new Error(`Promise instead of stream passed in at index ${idx}`);\n\t\t}\n\t\tif (idx === lastIndex && stream.getWriter) {\n\t\t\treturn pipeline.pipeTo(stream);\n\t\t}\n\t\treturn pipeline.pipeThrough(stream);\n\t});\n};\n\nexport const result = async (streams) => {\n\tconst output = {};\n\tfor (const stream of streams) {\n\t\tif (typeof stream.result === \"function\") {\n\t\t\tconst { key, value } = await stream.result();\n\t\t\tif (key) {\n\t\t\t\toutput[key] = value;\n\t\t\t}\n\t\t}\n\t}\n\treturn output;\n};\n\nexport const streamToArray = async (stream) => {\n\tconst value = [];\n\tfor await (const chunk of stream) {\n\t\tvalue.push(chunk);\n\t}\n\treturn value;\n};\n\nexport const streamToObject = async (stream) => {\n\tconst value = {};\n\tfor await (const chunk of stream) {\n\t\tObject.assign(value, chunk);\n\t}\n\treturn value;\n};\n\nexport const streamToString = async (stream) => {\n\tlet value = \"\";\n\tfor await (const chunk of stream) {\n\t\tvalue += chunk;\n\t}\n\treturn value;\n};\n\nexport const isReadable = (stream) => {\n\treturn stream instanceof ReadableStream || !!stream.readable;\n};\n\nexport const isWritable = (stream) => {\n\treturn stream instanceof WritableStream || !!stream.writable;\n};\n\nexport const makeOptions = ({\n\thighWaterMark,\n\tchunkSize,\n\tsignal,\n\t...streamOptions\n} = {}) => {\n\treturn {\n\t\twritableStrategy: {\n\t\t\thighWaterMark,\n\t\t\tsize: { chunk: chunkSize },\n\t\t},\n\t\treadableStrategy: {\n\t\t\thighWaterMark,\n\t\t\tsize: { chunk: chunkSize },\n\t\t},\n\t\tsignal,\n\t\t...streamOptions,\n\t};\n};\n\nexport const createReadableStream = (input, streamOptions = {}) => {\n\tconst queued = [];\n\tconst stream = new ReadableStream(\n\t\t{\n\t\t\tasync start(controller) {\n\t\t\t\twhile (queued.length) {\n\t\t\t\t\tconst chunk = queued.shift();\n\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t}\n\t\t\t\tif (typeof input === \"string\") {\n\t\t\t\t\tconst chunkSize = streamOptions?.chunkSize ?? 16 * 1024;\n\t\t\t\t\tlet position = 0;\n\t\t\t\t\tconst length = input.length;\n\t\t\t\t\twhile (position < length) {\n\t\t\t\t\t\tconst chunk = input.substring(position, position + chunkSize);\n\t\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\t\tposition += chunkSize;\n\t\t\t\t\t}\n\t\t\t\t\tcontroller.close();\n\t\t\t\t} else if (Array.isArray(input)) {\n\t\t\t\t\t// TODO update to for(;;) loop, faster\n\t\t\t\t\tfor (const chunk of input) {\n\t\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\t}\n\t\t\t\t\tcontroller.close();\n\t\t\t\t} else if ([\"function\", \"object\"].includes(typeof input)) {\n\t\t\t\t\tfor await (const chunk of input) {\n\t\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\t}\n\t\t\t\t\tcontroller.close();\n\t\t\t\t}\n\t\t\t},\n\t\t\tpull(controller) {\n\t\t\t\twhile (queued.length) {\n\t\t\t\t\tconst chunk = queued.shift();\n\t\t\t\t\tif (chunk === null) {\n\t\t\t\t\t\tcontroller.close();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\tmakeOptions(streamOptions),\n\t);\n\tstream.push = (chunk) => queued.push(chunk);\n\treturn stream;\n};\n\nexport const createPassThroughStream = (passThrough, flush, streamOptions) => {\n\tpassThrough ??= (_chunk) => {};\n\tif (typeof flush !== \"function\") {\n\t\tstreamOptions = flush;\n\t\tflush = undefined;\n\t}\n\treturn new TransformStream(\n\t\t{\n\t\t\tstart() {},\n\t\t\tasync transform(chunk, controller) {\n\t\t\t\tawait passThrough(chunk);\n\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t},\n\t\t\tasync flush(controller) {\n\t\t\t\tif (flush) {\n\t\t\t\t\tawait flush();\n\t\t\t\t}\n\t\t\t\tcontroller.terminate();\n\t\t\t},\n\t\t},\n\t\tmakeOptions(streamOptions),\n\t);\n};\n\nexport const createTransformStream = (transform, flush, streamOptions) => {\n\ttransform ??= (chunk, enqueue) => enqueue(chunk);\n\tif (typeof flush !== \"function\") {\n\t\tstreamOptions = flush;\n\t\tflush = undefined;\n\t}\n\treturn new TransformStream(\n\t\t{\n\t\t\tstart() {},\n\t\t\tasync transform(chunk, controller) {\n\t\t\t\tconst enqueue = (chunk, encoding) => {\n\t\t\t\t\tcontroller.enqueue(chunk, encoding);\n\t\t\t\t};\n\t\t\t\tawait transform(chunk, enqueue);\n\t\t\t},\n\t\t\tasync flush(controller) {\n\t\t\t\tif (flush) {\n\t\t\t\t\tconst enqueue = (chunk, encoding) => {\n\t\t\t\t\t\tcontroller.enqueue(chunk, encoding);\n\t\t\t\t\t};\n\t\t\t\t\tawait flush(enqueue);\n\t\t\t\t}\n\t\t\t\tcontroller.terminate();\n\t\t\t},\n\t\t},\n\t\tmakeOptions(streamOptions),\n\t);\n};\n\nexport const createWritableStream = (write, close, streamOptions) => {\n\twrite ??= () => {};\n\tif (typeof close !== \"function\") {\n\t\tstreamOptions = close;\n\t\tclose = undefined;\n\t}\n\treturn new WritableStream(\n\t\t{\n\t\t\tasync write(chunk) {\n\t\t\t\tawait write(chunk);\n\t\t\t},\n\t\t\tasync close() {\n\t\t\t\tif (close) {\n\t\t\t\t\tawait close();\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\tmakeOptions(streamOptions),\n\t);\n};\n\nexport const timeout = (ms, { signal } = {}) => {\n\tif (signal?.aborted) {\n\t\treturn Promise.reject(new Error(\"Aborted\", \"AbortError\"));\n\t}\n\treturn new Promise((resolve, reject) => {\n\t\tconst abortHandler = () => {\n\t\t\tclearTimeout(timeout);\n\t\t\treject(new Error(\"Aborted\", \"AbortError\"));\n\t\t};\n\t\tif (signal) signal.addEventListener(\"abort\", abortHandler);\n\t\tsetTimeout(() => {\n\t\t\tresolve();\n\t\t\tif (signal) signal.removeEventListener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"", | ||
| "version": "0.1.4", | ||
| "description": "Stream creation utilities and pipeline functions for Web Streams API and Node.js streams", | ||
| "type": "module", | ||
@@ -13,3 +13,3 @@ "engines": { | ||
| }, | ||
| "main": "./index.web.mjs", | ||
| "main": "./index.node.mjs", | ||
| "module": "./index.web.mjs", | ||
@@ -22,6 +22,2 @@ "exports": { | ||
| "default": "./index.node.mjs" | ||
| }, | ||
| "__require": { | ||
| "types": "./index.d.ts", | ||
| "default": "./index.node.cjs" | ||
| } | ||
@@ -42,3 +38,2 @@ }, | ||
| "*.mjs", | ||
| "*.cjs", | ||
| "*.map", | ||
@@ -72,6 +67,4 @@ "*.d.ts" | ||
| "devDependencies": { | ||
| "@datastream/core": "0.0.42", | ||
| "@datastream/object": "0.0.42" | ||
| }, | ||
| "gitHead": "6ddc0fadabf5f3702a51aebae1fc6b252c6ae8d4" | ||
| "@datastream/object": "0.1.4" | ||
| } | ||
| } |
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
50847
29.46%1
-50%7
40%678
34.26%0
-100%53
Infinity%