line-stream-util
v1.2.2
Published
utilities for line based stream
Downloads
1,720
Readme
line-stream-util
Install
npm i line-stream-util
Requires
var sutil = require('line-stream-util')
var fs = require('fs')
split lines with '\n'
fs.createReadStream('a.txt')
.pipe(sutil.split()) // split lines
.setEncoding('utf8')
.on('data', console.log)
join lines with '\n'
fs.createReadStream('a.txt')
.pipe(sutil.split())
.pipe(sutil.join()) // join lines
.pipe(fs.createWriteStream('b.txt'))
get head lines
fs.createReadStream('test/a.txt')
.pipe(sutil.head(1)) // get head lines
.pipe(sutil.split())
.setEncoding('utf8')
.on('data', console.log)
remove head lines
fs.createReadStream('test/a.txt')
.pipe(sutil.removeHead(2)) // remove 2 line
.on('data', console.log)