Traditionally, in synchronous languages a task such as having two nested foreach loops conditionally exit would be an easy task such as:
return new Promise(resolve, reject){
AnArray.forEach(anElement){
ACONSTANTARRAY.forEach(ACONSTANTELEMENT){
if(anElement === ACONSTANTELEMENT){
resolve(bar);
}
}
}
resolve(foo);
}
However, because foo will be resolved immediately what is the best way to handle this situation? Will I have to transform this into multiple Promise.all(array.map(function(){})
calls? Seems ugly, overly complex, and hard to understand.