
Security News
TypeScript is Porting Its Compiler to Go for 10x Faster Builds
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
linebyline
Advanced tools
Read a file line by line.
npm install linebyline
npm install .
npm test
Simple streaming readline module for NodeJS. Reads a file and buffers new lines emitting a line event for each line.
var readline = require('linebyline'),
rl = readline('./somefile.txt');
rl.on('line', function(line, lineCount, byteCount) {
// do something with the line of text
})
.on('error', function(e) {
// something went wrong
});
As the underlying fs.createReadStream
doesn't care about the specific ASCII encoding of the file, an alternative way to decode the file is by telling the readline
library to retain buffer and then decoding it using a converter (e.g. iconv-lite
).
var readline = require('linebyline'),
rl = readline('./file-in-win1251.txt', {
retainBuffer: true //tell readline to retain buffer
});
rl.on("line", function (data,linecount){
var line = iconv.decode(data, 'win1251');
// do something with the line of converted text
});
##API
readingObject
- file path or stream objectoptions
can include:
maxLineLength
- override the default 4K buffer size (lines longer than this will not be read)retainBuffer
- avoid converting to String prior to emitting 'line' event; will pass raw buffer with encoded data to the callbackBSD © Craig Brookes
FAQs
Simple streaming readline module.
The npm package linebyline receives a total of 5,745 weekly downloads. As such, linebyline popularity was classified as popular.
We found that linebyline 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
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.