Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Chops a stream into pieces using a delimiter.
$ npm install chopper
The object created from StreamChopper() lets you read a line at a time from a stream in a throttled manner:
require("chopper");
stream = process.stdin
var chopper = new StreamChopper(stream, "\n", function(line) {
chopper.pause();
console.log(line);
setTimeout(function() {
chopper.resume();
}, 500);
});
This outputs a line at a time with a 1/2 second delay between each.
All three arguments to the constructor are required.
The object created from Chopper() cuts the stream into delimited pieces, but does not throttle itself at all. The stream for Chopper() is just sequentials calls to feed it more data via next().
Chopper() can be used 3 different ways.
This:
log = console.log
var chopper = new Chopper("\0");
log(chopper.next('{"seq":0}\0'));
log(chopper.next('{"seq":1}\0'));
log(chopper.next('{"seq":'));
log(chopper.next('2}\0'));
log(chopper.next('{"seq":3}\0{"seq":4}\0'));
log(chopper.next('{"seq":5}\0{'));
log(chopper.next('"seq":6}\0'));
log(chopper.next('\0'));
log(chopper.next('{"seq":7}\0{"seq":8}\0{"seq":9}'));
log(chopper.next('\0{"seq":10}'));
Outputs:
[ '{"seq":0}' ]
[ '{"seq":1}' ]
[]
[ '{"seq":2}' ]
[ '{"seq":3}', '{"seq":4}' ]
[ '{"seq":5}' ]
[ '{"seq":6}' ]
[ '' ]
[ '{"seq":7}', '{"seq":8}' ]
[ '{"seq":9}' ]
This:
var chopper = new Chopper("\n");
var f = function(m) { log(m) }
chopper.next('{"seq":0}\n', f)
chopper.next('{"seq":1}\n', f)
chopper.next('{"seq":', f)
chopper.next('2}\n', f)
chopper.next('{"seq":3}\n{"seq":4}\n', f)
chopper.next('{"seq":5}\n{', f)
chopper.next('"seq":6}\n', f)
chopper.next('\n', f)
chopper.next('{"seq":7}\n{"seq":8}\n{"seq":9}', f)
chopper.next('\n{"seq":10}', f)
Outputs this:
{"seq":0}
{"seq":1}
{"seq":2}
{"seq":3}
{"seq":4}
{"seq":5}
{"seq":6}
{"seq":7}
{"seq":8}
{"seq":9}
This:
var f = function(m) { log(m) }
var chopper = new Chopper("\n", f);
chopper.next('Hello.\nGoodbye.\n')
chopper.next('Why')
chopper.next(' are you')
chopper.next(' here?\nI do not know.')
chopper.next('\nok')
Outputs this:
Hello.
Goodbye.
Why are you here?
I do not know.
The "ok" string at the end isn't recognized as it isn't terminated with \n.
If you find errors please send me pull requests with repairs.
FAQs
Cuts a stream into discrete pieces using a delimiter
We found that chopper 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
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.