fix(core): update
This commit is contained in:
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/smartstream',
|
||||
version: '3.0.17',
|
||||
version: '3.0.18',
|
||||
description: 'simplifies access to node streams'
|
||||
}
|
||||
|
@ -130,6 +130,9 @@ export class SmartDuplex<TInput = any, TOutput = any> extends Duplex {
|
||||
}
|
||||
|
||||
public notBackpressured = true;
|
||||
public get backpressured(): boolean {
|
||||
return !this.notBackpressured;
|
||||
}
|
||||
public push(chunkArg?: TOutput | null): boolean {
|
||||
const result = super.push(chunkArg);
|
||||
if (!result && this.handleBackpressure) {
|
||||
@ -161,9 +164,17 @@ export class SmartDuplex<TInput = any, TOutput = any> extends Duplex {
|
||||
try {
|
||||
const modifiedChunk = await this.writeFunction(chunk, tools);
|
||||
if (modifiedChunk) {
|
||||
this.push(modifiedChunk);
|
||||
this.push(modifiedChunk)
|
||||
if (this.backpressured && this.handleBackpressure) {
|
||||
this.once('drain', () => {
|
||||
callback();
|
||||
});
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
callback();
|
||||
} catch (err) {
|
||||
callback(err);
|
||||
}
|
||||
|
Reference in New Issue
Block a user