Skip to content

Instantly share code, notes, and snippets.

@jsscclr
Created July 25, 2015 04:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsscclr/724c6784f36d69401159 to your computer and use it in GitHub Desktop.
Save jsscclr/724c6784f36d69401159 to your computer and use it in GitHub Desktop.
var http = require('http')
var bl = require('bl')
var results = []
var count = 0
function printResults () {
for (var i = 0; i < 3; i++)
console.log(results[i])
}
function httpGet (index) {
http.get(process.argv[2 + index], function (response) {
response.pipe(bl(function (err, data) {
if (err)
return console.error(err)
results[index] = data.toString()
count++
if (count == 3)
printResults()
}))
})
}
for (var i = 0; i < 3; i++)
httpGet(i)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment