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