Skip to content

Instantly share code, notes, and snippets.

@robotlolita
Forked from cbradwell/new.js
Last active Feb 2, 2016
Embed
What would you like to do?
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