
Security News
Open Source CAI Framework Handles Pen Testing Tasks up to 3,600× Faster Than Humans
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
async-stream-reader
Advanced tools
An async way to read stream
Sometime you may want to read something from a stream, typically a file stream, in an async-await style. This tool may help you by providing an async read method for streams.
The async-stream-reader
holds events and returns them one by one every time async StreamReader#next
get called. If async-stream-reader
has got some events in the holder, it will try to pause the input stream, and resume it if the holder get empty.
So as long as the input stream supports pause
and resume
, you can just do your work at each frame of data at ease, without worring missing something, or memory consumed in large quantities
const fs = require('fs');
const readline = require('readline');
const StreamReader = require('async-stream-reader');
const rl = readline.createInterface({
input: fs.createReadStream("./foo.txt");
});
const reader = new StreamReader(rl, {
events: { data: 'line', end: 'close' },
});
async main() {
let line;
while (line = await reader.next()) {
console.log(line);
}
}
main().catch(error => console.log(error));
undefined
or options.end
will be returned.reader.next()
get called and consumes the error on the head of the queue.Thanks @Divvito for rewriting this in typescript version.
FAQs
A stream reader with async functions
We found that async-stream-reader demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.