Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
n-readlines-next
Advanced tools
Read file line by line without buffering the whole file in memory.
node-readlines-next
is a fork of node-readlines
! A package developed by Yoan Arnaudov! Original Repo here
The author wasn't active for 2 years up to now!
I took the deliberate to Fork it! Merged one PR (One bring better performance) [check here]! And added typescript declarations!
Also if any PR are send! I'll make sure to treat them!
Reading file line by line may seem like a trivial problem, but in node, there is no straightforward way to do it. There are a lot of libraries using Transform Streams to achieve it, but it seems like a overkill, so I've wrote simple version using only the filesystem
module of node. Note that this is synchronous library.
Install with
npm install n-readlines-next
Arguments
filename
- String path to the file you want to read fromfd
- File descriptoroptions
- Object
readChunk
- Integer number of bytes to read at once. Default: 1024newLineCharacter
- String new line character, only works with one byte characters for now. Default: \n
which is 0x0a
hex encodednode-readlines
can handle files without newLineCharacter after the last line
Returns buffer
with the line data without the newLineCharacter
or false
if end of file is reached.
Resets the pointer and starts from the beginning of the file. This works only if the end is not reached.
var ReadLines = require('n-readlines');
var liner = new ReadLines('./textFile.txt');
var line;
var lineNumber = 0;
while (line = liner.next()) {
console.log('Line ' + lineNumber + ': ' + line.toString('ascii'));
lineNumber++;
}
console.log('end of line reached');
For imports and types
import LineReader, { ReadLinesOptions } from 'n-readlines-next';
export class CsvReader {
private _lineReader: LineReader;
}
FAQs
Read file line by line without buffering the whole file in memory.
The npm package n-readlines-next receives a total of 133 weekly downloads. As such, n-readlines-next popularity was classified as not popular.
We found that n-readlines-next 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.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.