stringstream
Advanced tools
Comparing version 0.0.0 to 0.0.1
{ | ||
"name": "stringstream", | ||
"version": "0.0.0", | ||
"description": "Encode and decode data streams into string streams", | ||
"version": "0.0.1", | ||
"description": "Encode and decode streams into string streams", | ||
"main": "stringstream.js", | ||
@@ -6,0 +6,0 @@ "scripts": { |
@@ -1,2 +0,35 @@ | ||
# Encode and decode streams into string streams (aka encoding the right | ||
way) | ||
# Decode streams into strings The Right Way(tm) | ||
```javascript | ||
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: | ||
```javascript | ||
// 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: | ||
```javascript | ||
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) | ||
}) | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Empty package
Supply chain riskPackage does not contain any code. It may be removed, is name squatting, or the result of a faulty package publish.
Found 1 instance in 1 package
3865
5
56
36
0