
Research
/Security News
Popular Tinycolor npm Package Compromised in Supply Chain Attack Affecting 40+ Packages
Malicious update to @ctrl/tinycolor on npm is part of a supply-chain attack hitting 40+ packages across maintainers
line-readable-stream
Advanced tools
Provides a stream wrapper for a node.js Readable Stream for line-by-line reading
This is a port of bluesmoon's node-line.input-stream. Provides a stream wrapper for a node.js Readable Stream for line-by-line reading.
Node:
npm install line-readable-stream
Like Readable Stream with a line
event.
JavaScript:
var LineReadableStream = require('line-readable-stream');
var fs = require('fs');
var stream = new LineReadableStream(fs.createReadStream("foo.txt", { flags: "r" }));
stream.setEncoding("utf8");
stream.setDelimiter("\n"); // optional string, defaults to "\n"
stream.on("error", function(err) {
console.log(err);
});
stream.on("data", function(chunk) {
// You don't need to use this event
});
stream.on("line", function(line) {
// Sends you lines from the stream delimited by delimiter
});
stream.on("end", function() {
// No more data, all line events emitted before this event
});
stream.on("close", function() {
// Same as ReadableStream's close event
});
if(stream.readable) {
console.log("stream is readable");
}
// Also available: resume(), pipe()
TypeScript:
///<require path="typings/node/node.d.ts"/>
///<require path="node_modules/line-readable-stream/LineReadableStream.d.ts"/>
// If you know a better war to include the .ts file that comes with the npm package, let me know.
import LineReadableStream = require('node_modules/line-readable-stream/LineReadableStream');
import fs = require('fs');
var stream = new LineReadableStream(fs.createReadStream("foo.txt", { flags: "r" }));
stream.setEncoding("utf8");
stream.setDelimiter("\n"); // optional string, defaults to "\n"
stream.on("error", err => console.log(err));
stream.on("data", chunk => {
// You don't need to use this event
});
stream.on("line", line => {
// Sends you lines from the stream delimited by delimiter
console.log("Line: " + line);
});
stream.on("end", () => {
// No more data, all line events emitted before this event
});
stream.on("close", () => {
// Same as ReadableStream's close event
});
if(stream.readable)
console.log("stream is readable");
// Also available: resume(), pipe()
You can also attach listeners to any event specific to the underlying stream, ie,
you can listen to the open
event for streams created by fs.createReadStream()
or the connect
event for Net streams.
A side effect of this is that you can add a listener for any junk string and LineReadableStream
will
pretend that it worked. The event listener may never be called though.
line
handlerline-readable-stream
, you can delimit by any string, so for example, setting delimiter to "\n\n"
will read by paragraph (sort of)./[\r\n]+/
this
, so can be chainedFAQs
Provides a stream wrapper for a node.js Readable Stream for line-by-line reading
We found that line-readable-stream 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
Malicious update to @ctrl/tinycolor on npm is part of a supply-chain attack hitting 40+ packages across maintainers
Security News
pnpm's new minimumReleaseAge setting delays package updates to prevent supply chain attacks, with other tools like Taze and NCU following suit.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.