stringstream

0.0.1 • Public • Published

Decode streams into strings The Right Way(tm)

fs = require('fs')
zlib = require('zlib')
strs = require('stringstream')

var stream = fs.createReadStream('massiveLogFile.gz')
  .pipe(zlib.createGunzip())
  .pipe(strs('utf8'))

No need to deal with setEncoding() weirdness, just compose streams like they were supposed to be!

Handles input and output encoding:

// Stream from utf8 to hex to base64... Why not ay.
fs.createReadStream('myFile').pipe(strs('utf8', 'hex')).pipe(strs('hex', 'base64'))

Also deals with base64 output correctly by aligning each emitted data chunk so that there are no dangling = characters:

var stream = fs.createReadStream('massiveLogFile.gz').pipe(strs('base64'))

var fileStr = ''

stream.on('data', function(data) { fileStr += data })
stream.on('end', function() {
  console.log('My base64 encoded file is: ' + fileStr)
})

Readme

Keywords

none

Package Sidebar

Install

npm i stringstream@0.0.1

Version

0.0.1

License

BSD

Last publish

Collaborators

  • hichaelmart