Created
June 20, 2016 12:03
-
-
Save iokasimov/18efab6739e5586640e2f039e39d778b to your computer and use it in GitHub Desktop.
This file contains 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
var path = require('path'); | |
var async = require('async'); | |
var config = require(path.join(process.cwd() + '/src/config')); | |
var processor = require(path.join(process.cwd() + '/src/processor')); | |
var continents = ['australia','north-america','europe']; | |
var p = new processor.Processor(); | |
// asynchonously parsing each continent | |
var main = function (continets, on_complete) { | |
var counter = 0; | |
var agencies = []; | |
on_complete = function (err, data) { | |
agencies = agencies.concat(data); | |
counter++; | |
if (counter === continents.length) { | |
return agencies; | |
} | |
} | |
async.each(continents, | |
function (url, next) { | |
p.process(url, on_complete); | |
}, | |
function (err) { | |
console.log(agencies); | |
if (err) { | |
console.log(err); | |
} | |
} | |
); | |
} | |
main(continents, function(err, data){ | |
console.log(data); | |
}); | |
module.exports = main; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment