From 8efb2b109379bb28a9b42f8a22cf5927d4f829f8 Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Mon, 6 Nov 2023 22:10:20 +0100 Subject: [PATCH] fix(core): update --- ts/00_commitinfo_data.ts | 2 +- ts/smartstream.classes.smartduplex.ts | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 7e1de78..b3b9d29 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: '3.0.10', + version: '3.0.11', description: 'simplifies access to node streams' } diff --git a/ts/smartstream.classes.smartduplex.ts b/ts/smartstream.classes.smartduplex.ts index e2eb526..3073c01 100644 --- a/ts/smartstream.classes.smartduplex.ts +++ b/ts/smartstream.classes.smartduplex.ts @@ -109,15 +109,15 @@ export class SmartDuplex extends Duplex { // INSTANCE private readFunction?: () => Promise; - private writeAndTransformFunction?: IWriteAndTransformFunction; - private streamEndFunction?: IStreamEndFunction; + private writeFunction?: IWriteAndTransformFunction; + private finalFunction?: IStreamEndFunction; private observableSubscription?: plugins.smartrx.rxjs.Subscription; constructor(optionsArg?: SmartStreamOptions) { super(optionsArg); this.readFunction = optionsArg?.readFunction; - this.writeAndTransformFunction = optionsArg?.writeAndTransformFunction; - this.streamEndFunction = optionsArg?.finalFunction; + this.writeFunction = optionsArg?.writeAndTransformFunction; + this.finalFunction = optionsArg?.finalFunction; } public async _read(size: number): Promise { @@ -128,7 +128,7 @@ export class SmartDuplex extends Duplex { // Ensure the _write method types the chunk as TInput and encodes TOutput public async _write(chunk: TInput, encoding: string, callback: (error?: Error | null) => void) { - if (!this.writeAndTransformFunction) { + if (!this.writeFunction) { return callback(new Error('No stream function provided')); } @@ -141,7 +141,7 @@ export class SmartDuplex extends Duplex { }; try { - const modifiedChunk = await this.writeAndTransformFunction(chunk, tools); + const modifiedChunk = await this.writeFunction(chunk, tools); if (modifiedChunk) { if (!this.push(modifiedChunk)) { // Handle backpressure if necessary @@ -154,24 +154,24 @@ export class SmartDuplex extends Duplex { } public async _final(callback: (error?: Error | null) => void) { - if (this.streamEndFunction) { + if (this.finalFunction) { const tools: IStreamTools = { truncate: () => callback(), push: (pipeObject) => this.push(pipeObject), }; try { - const finalChunk = await this.streamEndFunction(tools); + const finalChunk = await this.finalFunction(tools); if (finalChunk) { this.push(finalChunk); } - callback(); } catch (err) { callback(err); } } else { - callback(); + // nothing here } this.push(null); + callback(); } }