From 2e1aa4a8ff0244d01a4a30fb59c34b0a1454bb1c Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Mon, 13 Nov 2023 19:06:02 +0100 Subject: [PATCH] fix(core): update --- test/assets/writabletext.txt | 38 --------------------------- test/test.backpressure.ts | 1 + test/test.smartstream.ts | 4 +-- ts/00_commitinfo_data.ts | 2 +- ts/smartstream.classes.smartduplex.ts | 8 +++--- 5 files changed, 7 insertions(+), 46 deletions(-) diff --git a/test/assets/writabletext.txt b/test/assets/writabletext.txt index e922c03..413e9db 100644 --- a/test/assets/writabletext.txt +++ b/test/assets/writabletext.txt @@ -10,41 +10,3 @@ hi+wow hi+wow hi+wow hi+wow -hi+wow -hi+wow -hi+wow -hi+wow -hi+wow -hi+wow -hi+wow -hi+wow -hi+wow -hi+wow -hi+wow -hi+wow -hi+wow -hi+wow -hi+wow -hi+wow -hi+wow -hi+wow -hi+wow -hi+wow -hi+wow -hi+wow -hi+wow -hi+wow -hi+wow -hi+wow -hi+wow -hi+wow -hi+wow -hi+wow -hi+wow -hi+wow -hi+wow -hi+wow -hi+wow -hi+wow -hi+wow -hi+wow diff --git a/test/test.backpressure.ts b/test/test.backpressure.ts index a93ab49..03ca798 100644 --- a/test/test.backpressure.ts +++ b/test/test.backpressure.ts @@ -19,6 +19,7 @@ tap.test('should run backpressure test', async (toolsArg) => { writeFunction: async (chunk, tools) => { await new Promise((resolve) => setTimeout(resolve, 20)); // Slow processing console.log(`processed chunk ${chunk} in stream 2`); + // await tools.push(chunk); return chunk; }, }); // This stream processes data more slowly diff --git a/test/test.smartstream.ts b/test/test.smartstream.ts index e89ce27..1464bd6 100644 --- a/test/test.smartstream.ts +++ b/test/test.smartstream.ts @@ -5,9 +5,7 @@ import * as fs from 'fs'; tap.test('should create a SmartStream from a Buffer', async () => { const bufferData = Buffer.from('This is a test buffer'); - const smartStream = SmartDuplex.fromBuffer(bufferData, { - handleBackpressure: false, - }); + const smartStream = SmartDuplex.fromBuffer(bufferData, {}); let receivedData = Buffer.alloc(0); diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 3951350..fed5dfe 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.23', + version: '3.0.24', description: 'simplifies access to node streams' } diff --git a/ts/smartstream.classes.smartduplex.ts b/ts/smartstream.classes.smartduplex.ts index acf6282..efbe9c7 100644 --- a/ts/smartstream.classes.smartduplex.ts +++ b/ts/smartstream.classes.smartduplex.ts @@ -115,22 +115,22 @@ export class SmartDuplex extends Duplex { const tools: IStreamTools = { truncate: () => callback(), push: async (pipeObject) => { - this.push(pipeObject); + this.backpressuredArray.push(pipeObject); }, }; try { const finalChunk = await this.options.finalFunction(tools); if (finalChunk) { - this.push(finalChunk); + this.backpressuredArray.push(finalChunk); } } catch (err) { - this.push(null); + this.backpressuredArray.push(null); callback(err); return; } } - this.push(null); + this.backpressuredArray.push(null); callback(); } }