Created
April 14, 2017 05:03
-
-
Save z3t0/d9eadfb00e2c0d1f4dc56186643a08d6 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
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