Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

stringstream

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stringstream

Encode and decode streams into string streams

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.6M
increased by44.08%
Maintainers
1
Weekly downloads
 
Created
Source

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)
})

FAQs

Package last updated on 23 Jun 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc