You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
From running the below code, it seems that async.every() is short-cutting if a falsy value is returned from an iterator. It would be nice to have this documented, so others don't have to try it out as I did:
async.every([1, 2], function(n, cbEvery) {
if (n ==1) {
return setTimeout(function() {
cbEvery(true)
console.log('validated')
}, 1000)
} else {
cbEvery(false)
}
}, function(valid) {
console.log('is valid:', valid)
})
// prints out "is valid: false" BEFORE "validated"
To give this some context: I am running validation on a collection and would like to collect all errors as well as the final isValid boolean. With every() however, I can only get the first failing error and from looking at issue 125 I was under the impression that all iterators would run. Could you please clarify.
The text was updated successfully, but these errors were encountered:
From running the below code, it seems that
async.every()
is short-cutting if a falsy value is returned from an iterator. It would be nice to have this documented, so others don't have to try it out as I did:To give this some context: I am running validation on a collection and would like to collect all errors as well as the final
isValid
boolean. Withevery()
however, I can only get the first failing error and from looking at issue 125 I was under the impression that all iterators would run. Could you please clarify.The text was updated successfully, but these errors were encountered: