Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
91392e8bd5 | |||
d161d6613a |
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@push.rocks/smartstream",
|
"name": "@push.rocks/smartstream",
|
||||||
"version": "3.0.17",
|
"version": "3.0.18",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "simplifies access to node streams",
|
"description": "simplifies access to node streams",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
|
@ -29,7 +29,7 @@ tap.test('should handle a read stream', async (tools) => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
// await streamWrapper.run();
|
await streamWrapper.run();
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should create a valid Intake', async (tools) => {
|
tap.test('should create a valid Intake', async (tools) => {
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@push.rocks/smartstream',
|
name: '@push.rocks/smartstream',
|
||||||
version: '3.0.17',
|
version: '3.0.18',
|
||||||
description: 'simplifies access to node streams'
|
description: 'simplifies access to node streams'
|
||||||
}
|
}
|
||||||
|
@ -130,6 +130,9 @@ export class SmartDuplex<TInput = any, TOutput = any> extends Duplex {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public notBackpressured = true;
|
public notBackpressured = true;
|
||||||
|
public get backpressured(): boolean {
|
||||||
|
return !this.notBackpressured;
|
||||||
|
}
|
||||||
public push(chunkArg?: TOutput | null): boolean {
|
public push(chunkArg?: TOutput | null): boolean {
|
||||||
const result = super.push(chunkArg);
|
const result = super.push(chunkArg);
|
||||||
if (!result && this.handleBackpressure) {
|
if (!result && this.handleBackpressure) {
|
||||||
@ -161,9 +164,17 @@ export class SmartDuplex<TInput = any, TOutput = any> extends Duplex {
|
|||||||
try {
|
try {
|
||||||
const modifiedChunk = await this.writeFunction(chunk, tools);
|
const modifiedChunk = await this.writeFunction(chunk, tools);
|
||||||
if (modifiedChunk) {
|
if (modifiedChunk) {
|
||||||
this.push(modifiedChunk);
|
this.push(modifiedChunk)
|
||||||
}
|
if (this.backpressured && this.handleBackpressure) {
|
||||||
|
this.once('drain', () => {
|
||||||
callback();
|
callback();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
callback(err);
|
callback(err);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user