Skip to content

Instantly share code, notes, and snippets.

@faiq
Created January 23, 2015 05:18
Show Gist options
  • Save faiq/c99459fcc54ded7fe783 to your computer and use it in GitHub Desktop.
Save faiq/c99459fcc54ded7fe783 to your computer and use it in GitHub Desktop.
var fs = require('fs')
, es = require('event-stream')
, JSONStream = require('JSONStream')
fs.createReadStream(__dirname + '/tests/mock.json')
.pipe(JSONStream.parse('items.*.exportLinks'))
.pipe(es.map(function (data, callback) {
if (data['text/csv']) callback(null,data['text/csv'])
else callback(null)
})) //this gets each url...
//ideally the following stream would be a request stream
//with a dynamic url property
.pipe(es.map(function(data, cb) {
console.log(data)
process.exit(1)
}))
.pipe(JSONStream.stringify())
.pipe(process.stdout)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment