Skip to content

Instantly share code, notes, and snippets.

@robotlolita
Forked from cbradwell/new.js
Last active February 2, 2016 17:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robotlolita/9068d34aa4bc74a590d7 to your computer and use it in GitHub Desktop.
Save robotlolita/9068d34aa4bc74a590d7 to your computer and use it in GitHub Desktop.
var async = require('async');
async.eachSeries(array, function(item, callback){
callAsyncFunction(item, function(error, data) {
if (error) {
return callback(error);
} else {
async.eachSeries(arrayTwo, function(sItem, sCallback) {
count++;
callAnotherAsyncFunction(item + sItem, function(error, data) {
if (error) {
return callback(error);
} else {
sCallback();
}
})
});
}
})
});
function doSomething(item) {
return callAsyncFunction(item).then(function(data) {
return Promise.all(arrayTwo.map(sItem => doSomethingElse(item, sItem)));
})
}
function doSomethingElse(item, sItem) {
count++;
return callAnotherAsyncFunction(item + sItem);
}
array.map(doSomething);
for (let item of array) {
let x = await callAsyncFunction(item);
for (let sItem of arrayTwo) {
let y = await callAnotherAsyncFunction(item + sItem)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment