Skip to content

Instantly share code, notes, and snippets.

@kunle
Last active September 28, 2015 17:31
Show Gist options
  • Save kunle/c314d618185cdab0e3a9 to your computer and use it in GitHub Desktop.
Save kunle/c314d618185cdab0e3a9 to your computer and use it in GitHub Desktop.
function doIt(someArray){
var result = [];
var realResult = [];
someArray.forEach(function(ele){
result.push(doPromise(ele))
});
function doPromise(element){
return new Promise(function(resolve, reject){
if(element == null)reject('Dont send me garbage');
var response = 2 * element;
resolve(response);
})
}
return result;
}
Promise.all(doIt([1,2,3])).then(log);
function log(value){
console.log("Logging!",value);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment