
Research
/Security News
9 Malicious NuGet Packages Deliver Time-Delayed Destructive Payloads
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.
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
The npm package chopper receives a total of 12 weekly downloads. As such, chopper popularity was classified as not popular.
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.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.