
Research
Security News
The Landscape of Malicious Open Source Packages: 2025 Mid‑Year Threat Report
A look at the top trends in how threat actors are weaponizing open source packages to deliver malware and persist across the software supply chain.
@pnpm/byline
Advanced tools
@pnpm/byline
is a simple module providing a LineStream
.
streams2
(transform stream)pipe
stream = byline(stream);
pnpm add @pnpm/byline
or from source:
git clone git://github.com/pnpm/node-byline.git
cd node-byline
npm link
The byline
module can be used as a function to quickly wrap a readable stream:
var fs = require('fs'),
byline = require('@pnpm/byline');
var stream = byline(fs.createReadStream('sample.txt', { encoding: 'utf8' }));
The data
event then emits lines:
stream.on('data', function(line) {
console.log(line);
});
You just need to add one line to wrap your readable Stream
with a LineStream
.
var fs = require('fs'),
byline = require('@pnpm/byline');
var stream = fs.createReadStream('sample.txt');
stream = byline.createStream(stream);
stream.on('data', function(line) {
console.log(line);
});
byline
supports pipe
(though it strips the line endings, of course).
var stream = fs.createReadStream('sample.txt');
stream = byline.createStream(stream);
stream.pipe(fs.createWriteStream('nolines.txt'));
Alternatively, you can create a readable/writable "through-stream" which doesn't wrap any specific stream:
var stream = fs.createReadStream('sample.txt');
stream = byline.createStream(stream);
stream.pipe(fs.createWriteStream('nolines.txt'));
var input = fs.createReadStream('LICENSE');
var lineStream = byline.createStream();
input.pipe(lineStream);
var output = fs.createWriteStream('test.txt');
lineStream.pipe(output);
Node v0.10 added a new streams2 API. This allows the stream to be used in non-flowing mode and is preferred over the legacy pause() and resume() methods.
var stream = fs.createReadStream('sample.txt');
stream = byline.createStream(stream);
stream.on('readable', function() {
var line;
while (null !== (line = stream.read())) {
console.log(line);
}
});
The byline
transform stream can be directly manipulated like so:
var LineStream = require('@pnpm/byline').LineStream;
var input = fs.createReadStream('sample.txt');
var output = fs.createWriteStream('nolines.txt');
var lineStream = new LineStream();
input.pipe(lineStream);
lineStream.pipe(output);
By default byline skips empty lines, if you want to keep them, pass the keepEmptyLines
option in
the call to byline.createStream(stream, options)
or byline(stream, options)
.
npm test
Unlike other modules (of which there are many), @pnpm/byline
contains no:
pipe
FAQs
simple line-by-line stream reader
We found that @pnpm/byline demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
A look at the top trends in how threat actors are weaponizing open source packages to deliver malware and persist across the software supply chain.
Security News
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
Security News
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.