-
-
Notifications
You must be signed in to change notification settings - Fork 33.3k
Closed
Labels
feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.streamIssues and PRs related to the stream subsystem.Issues and PRs related to the stream subsystem.
Description
What is the problem this feature will solve?
It will make the code much easier to read/write when the current readable operators are not enough
What is the feature you are proposing to solve the problem?
Adding a non-static compose method so we can chain multiple operators together
it would like like this for example:
fs.createReadStream("./file.pcapng")
.compose(async function* (source) {
let block = Buffer.alloc(0);
for await (const chunk of source) {
block = Buffer.concat(block, chunk);
if (block.length < REQUIRED_BLOCK_SIZE_TO_GET_TO_TOTAL_LENGTH) {
continue;
}
const blockExpectedTotalSize = getTotalSizeFromBlock(block);
if (block.length < blockExpectedTotalSize) {
continue;
}
if (mergedBlock.length >= blockExpectedTotalSize) {
yield block.slice(0, blockExpectedTotalSize);
block = block.slice(blockExpectedTotalSize);
}
}
})
.map((blockBuffer) => parseBufferBasedOnBlockType(blockBuffer))
.filter((parsedBlock) => parsedblock.dest === "192.168.1.1")
.toArray();
What alternatives have you considered?
Using static compose
benjamingr and pimterry
Metadata
Metadata
Assignees
Labels
feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.streamIssues and PRs related to the stream subsystem.Issues and PRs related to the stream subsystem.