line-stream-util

1.2.2 • Public • Published

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)

Readme

Keywords

none

Package Sidebar

Install

npm i line-stream-util

Weekly Downloads

888

Version

1.2.2

License

ISC

Unpacked Size

4.24 kB

Total Files

8

Last publish

Collaborators

  • yinrong