Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
// load all dependencies
var request = require('request');
var async = require('async');
var urlExpander = require('expand-url');
// add your own array of links here
var data = [ "", ""
var counter=0;
var q = async.queue(function (shortUrl, callback) {
// expander function
urlExpander.expand(shortUrl, function(err, longUrl){
// log the short url and the expanded url in the console
console.log(shortUrl + "," + longUrl);
}, 100);
// runs the expander function for each data point
var i = 0;
while (i< data.length){
q.push(data[i], function (err) {
// tells you in your console when you're done
q.drain = function() {
console.log('all urls have been processed');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.