Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mmis1000/readlines
a multiline and non-flow implement for nodejs readline
https://github.com/mmis1000/readlines
Last synced: 9 days ago
JSON representation
a multiline and non-flow implement for nodejs readline
- Host: GitHub
- URL: https://github.com/mmis1000/readlines
- Owner: mmis1000
- Created: 2015-01-07T16:18:20.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2018-11-27T04:43:55.000Z (about 6 years ago)
- Last Synced: 2024-11-23T21:29:11.215Z (2 months ago)
- Language: CoffeeScript
- Size: 21.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Read big files or streams with better memory usage.
This currently only works with streams in non-flow mode.###usage
readlines = require ("lines-reader")
reader = new readlines(options)###options
fileName :
absolute / relative file path [optional]
actully remapped to your call location,
so use relative path to current file will work
input : streams [ignored if fileName was set, required]
output : streams [optional]
lines : number [prefetch lines before readable event was emited, default to 10]
preloadLinesRatio : number [a multifier for lines option, default to 2]
ignoreEmptyLine : boolean [ignore 0 byte lines, default to true]
macStyleLineEnd : boolean [use \r instead of \r?\n as line separator, default to false]
encode : null/string [output encode, default to null(buffer)]
maxBuffer : number [flush lines immediately if output buffer excceed this, default to lines * 256]###event
line : emit when new line, listen to this cause reader turn into flow mode
readable : emit when enough lines were prefetched
end : emit when source was closed and internal buffer flushed###example(flowMode)
readlines = require "lines-reader"
reader = new readlines({fileName : "../package.json", encode : "utf8"})
reader.on 'line', (line)->
console.log line
reader.pause()
setTimeout (()->
reader.resume()
), 1000
#print text with delay of each lineexample(non-flowMode)
readlines = require "lines-reader"
reader = new readlines({fileName : "../package.json", encode : "utf8"})
reader.once 'readable', ()->
read = ()->
line = reader.readline()
if line
console.log line
if !reader.exited
setTimeout read, 1000
read()