fix(smartduplex): Enhance documentation for read function in SmartDuplex

This commit is contained in:
2024-10-16 02:03:56 +02:00
parent f7e9636bf6
commit 3d58a01b29
4 changed files with 11 additions and 2 deletions

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@push.rocks/smartstream',
version: '3.2.2',
version: '3.2.3',
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.'
}

View File

@ -56,6 +56,10 @@ export class SmartDuplex<TInput = any, TOutput = any> extends Duplex {
readableStream: ReadableStream<T>
): SmartDuplex<T, T> {
const smartDuplex = new SmartDuplex<T, T>({
/**
* this function is called whenever the stream is being read from and at the same time if nothing is enqueued
* therefor it is important to always unlock the reader after reading
*/
readFunction: async () => {
const reader = readableStream.getReader();
const { value, done } = await reader.read();