Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
4fc82d0dc6 | |||
3d58a01b29 | |||
f7e9636bf6 | |||
f211cc8ddd |
11
changelog.md
11
changelog.md
@ -1,5 +1,16 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 2024-10-16 - 3.2.3 - fix(smartduplex)
|
||||||
|
Enhance documentation for read function in SmartDuplex
|
||||||
|
|
||||||
|
- Added inline comments to clarify the behavior and importance of unlocking the reader in the readFunction of SmartDuplex.fromWebReadableStream.
|
||||||
|
|
||||||
|
## 2024-10-16 - 3.2.2 - fix(SmartDuplex)
|
||||||
|
Fix issue with SmartDuplex fromWebReadableStream method
|
||||||
|
|
||||||
|
- Resolved a potential unhandled promise rejection in fromWebReadableStream method
|
||||||
|
- Ensured proper release of stream reader lock in case of read completion
|
||||||
|
|
||||||
## 2024-10-16 - 3.2.1 - fix(core)
|
## 2024-10-16 - 3.2.1 - fix(core)
|
||||||
Fix the order of operations in SmartDuplex _read method to ensure proper waiting for items.
|
Fix the order of operations in SmartDuplex _read method to ensure proper waiting for items.
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@push.rocks/smartstream",
|
"name": "@push.rocks/smartstream",
|
||||||
"version": "3.2.1",
|
"version": "3.2.3",
|
||||||
"private": false,
|
"private": false,
|
||||||
"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.",
|
"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.",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@push.rocks/smartstream',
|
name: '@push.rocks/smartstream',
|
||||||
version: '3.2.1',
|
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.'
|
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.'
|
||||||
}
|
}
|
||||||
|
@ -56,21 +56,19 @@ export class SmartDuplex<TInput = any, TOutput = any> extends Duplex {
|
|||||||
readableStream: ReadableStream<T>
|
readableStream: ReadableStream<T>
|
||||||
): SmartDuplex<T, T> {
|
): SmartDuplex<T, T> {
|
||||||
const smartDuplex = new 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 () => {
|
readFunction: async () => {
|
||||||
const reader = readableStream.getReader();
|
const reader = readableStream.getReader();
|
||||||
try {
|
|
||||||
while (true) {
|
|
||||||
const { value, done } = await reader.read();
|
const { value, done } = await reader.read();
|
||||||
if (value !== undefined) {
|
if (value !== undefined) {
|
||||||
smartDuplex.push(value);
|
smartDuplex.push(value);
|
||||||
}
|
}
|
||||||
|
reader.releaseLock();
|
||||||
if (done) {
|
if (done) {
|
||||||
smartDuplex.end();
|
smartDuplex.end();
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
reader.releaseLock();
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@push.rocks/smartstream',
|
name: '@push.rocks/smartstream',
|
||||||
version: '3.2.1',
|
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.'
|
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.'
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user