-
line-reader is a ES6 Generator function which returns an iterable to iterater over lines in a
file
orstdin
one by one using.next()
method orfor..of
loop. -
npm install git+https://github.com/Vikasg7/line-reader.git
-
import { LineReader } from "line-reader" // FromLine and ToLine are optional arguments const filePathOrStdin = "path-to-file.txt" || process.stdin const FromLine: number = 1 // default is 0 const ToLine: number = 5 // default is Infinity const chunkSizeInBytes = 8 * 1024 // default is 64 * 1024 const list: IterableIterator<string> = LineReader(filePathOrStdin, FromLine, ToLine, chunkSizeInBytes) // Call list.next to iterate over lines in a file list.next() // Iterating using a for..of loop for (const item of list) { console.log(item) }
-
Check the tests folder in src folder for an example.
-
Notifications
You must be signed in to change notification settings - Fork 0
Vikasg7/line-reader
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
NodeJs *Generator function to read a file line by line
Topics
Resources
Stars
Watchers
Forks
Packages 0
No packages published