Created
January 23, 2015 05:18
-
-
Save faiq/c99459fcc54ded7fe783 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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