fix(SmartDuplex): Fix issue with SmartDuplex fromWebReadableStream method
This commit is contained in:
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/smartstream',
|
||||
version: '3.2.1',
|
||||
version: '3.2.2',
|
||||
description: 'A library to simplify the creation and manipulation of Node.js streams, providing utilities for handling transform, duplex, and readable/writable streams effectively in TypeScript.'
|
||||
}
|
||||
|
@ -58,19 +58,13 @@ export class SmartDuplex<TInput = any, TOutput = any> extends Duplex {
|
||||
const smartDuplex = new SmartDuplex<T, T>({
|
||||
readFunction: async () => {
|
||||
const reader = readableStream.getReader();
|
||||
try {
|
||||
while (true) {
|
||||
const { value, done } = await reader.read();
|
||||
if (value !== undefined) {
|
||||
smartDuplex.push(value);
|
||||
}
|
||||
if (done) {
|
||||
smartDuplex.end();
|
||||
break;
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
reader.releaseLock();
|
||||
const { value, done } = await reader.read();
|
||||
if (value !== undefined) {
|
||||
smartDuplex.push(value);
|
||||
}
|
||||
reader.releaseLock();
|
||||
if (done) {
|
||||
smartDuplex.end();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
Reference in New Issue
Block a user