Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

AsyncMap error result question #3

Closed
dannycoates opened this issue Feb 26, 2011 · 2 comments
Closed

AsyncMap error result question #3

dannycoates opened this issue Feb 26, 2011 · 2 comments

Comments

@dannycoates
Copy link

I love the simplicity of your slide functions and I have a question about the implementation. I don't see a case where the cb_ function is called with an errState. It looks like the chain of callbacks is short circuited and cb_ is never invoked when there's an error. Is this by design or am I incorrect? I've commented the line in question below. Thanks! Great slides btw, very informative!

module.exports = asyncMap
function asyncMap (list, fn, cb_) {
  var n = list.length
    , results = []
    , errState = null
  function cb (er, data) {
    if (errState) return
    if (er) return cb(errState = er) //should this be cb_ ?
    results.push(data)
    if (-- n === 0)
      return cb_(null, results)
  }
  if (list.length === 0) return cb_(null, [])
  list.forEach(function (l) {
    fn(l, cb)
  })
}
@isaacs
Copy link
Owner

isaacs commented Feb 27, 2011

Yep, that's a bug.

@isaacs
Copy link
Owner

isaacs commented Feb 27, 2011

Closed by 5846d8e typo

isaacs added a commit that referenced this issue Jul 20, 2011
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants