a zip code crypto-currency system good for red ONLY

example.js 814B

12345678910111213141516171819202122232425262728
  1. var fs = require('fs')
  2. var zlib = require('zlib')
  3. var strs = require('stringstream')
  4. var utf8Stream = fs.createReadStream('massiveLogFile.gz')
  5. .pipe(zlib.createGunzip())
  6. .pipe(strs('utf8'))
  7. utf8Stream.pipe(process.stdout)
  8. // Stream from utf8 to hex to base64... Why not, ay.
  9. var hex64Stream = fs.createReadStream('myFile')
  10. .pipe(strs('utf8', 'hex'))
  11. .pipe(strs('hex', 'base64'))
  12. hex64Stream.pipe(process.stdout)
  13. // Deals with base64 correctly by aligning chunks
  14. var stream = fs.createReadStream('myFile').pipe(strs('base64'))
  15. var base64Str = ''
  16. stream.on('data', function(data) { base64Str += data })
  17. stream.on('end', function() {
  18. console.log('My base64 encoded file is: ' + base64Str) // Wouldn't work with setEncoding()
  19. console.log('Original file is: ' + new Buffer(base64Str, 'base64'))
  20. })