Skip to content

Instantly share code, notes, and snippets.

@IPRIT
Created April 11, 2015 11:59
Show Gist options
  • Select an option

  • Save IPRIT/e7b330001a5943440c9b to your computer and use it in GitHub Desktop.

Select an option

Save IPRIT/e7b330001a5943440c9b to your computer and use it in GitHub Desktop.
var args = process.argv.slice(2);
var httpPipe = require('./http_pipe');
var queue = [], cur;
var httpGet = function(url) {
function callback(err, data) {
if (err) throw err;
console.log(data);
if (queue.length) {
cur = queue.shift();
httpPipe(cur, callback);
} else {
cur = null;
}
}
if (!cur) {
cur = url;
httpPipe(url, callback);
} else {
queue.push(url);
}
};
for (var i = 0; i < args.length; ++i) {
httpGet(args[i]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment