Skip to content

Instantly share code, notes, and snippets.

@z3t0
Created April 14, 2017 05:03
Show Gist options
  • Save z3t0/d9eadfb00e2c0d1f4dc56186643a08d6 to your computer and use it in GitHub Desktop.
Save z3t0/d9eadfb00e2c0d1f4dc56186643a08d6 to your computer and use it in GitHub Desktop.
const http = require('http')
// queue
let queue = []
function httpget (i) {
http.get(process.argv[i + 2], (res) => {
let all = ''
res.on('data', (data) => {
all += data.tostring()
})
res.on('end', () => {
console.log(i)
queue[i] = all
if (queue.length === 3) {
print()
}
})
})
}
for (var i = 0; i < process.argv.length - 2; i++) {
httpget(i)
}
function print () {
for (var i = 0; i < queue.length; i++) {
console.log(queue[i])
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment