From d1561ad1b7523efd7c2f8d56a17ab748839a6870 Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Thu, 2 Nov 2023 00:30:15 +0100 Subject: [PATCH] fix(core): update --- ts/00_commitinfo_data.ts | 2 +- ts/index.ts | 1 + ts/smartstream.classes.passthrough.ts | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 ts/smartstream.classes.passthrough.ts diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 088df35..a2b025d 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@push.rocks/smartstream', - version: '2.0.7', + version: '2.0.8', description: 'simplifies access to node streams' } diff --git a/ts/index.ts b/ts/index.ts index 116b3da..29426ef 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -1,3 +1,4 @@ +export * from './smartstream.classes.passthrough.js'; export * from './smartstream.classes.smartstream.js'; export * from './smartstream.classes.streamwrapper.js'; export * from './smartstream.classes.streamintake.js'; diff --git a/ts/smartstream.classes.passthrough.ts b/ts/smartstream.classes.passthrough.ts new file mode 100644 index 0000000..db62c9c --- /dev/null +++ b/ts/smartstream.classes.passthrough.ts @@ -0,0 +1,19 @@ +import * as plugins from './smartstream.plugins.js'; + +export class PassThrough extends plugins.stream.Duplex { + constructor(options?: plugins.stream.DuplexOptions) { + super(options); + } + + _read(size: number): void { + // No-op: Data written will be automatically available for reading. + } + + _write(chunk: any, encoding: BufferEncoding, callback: (error?: Error | null) => void): void { + if (this.push(chunk, encoding)) { + callback(); + } else { + this.once('drain', callback); + } + } +} \ No newline at end of file