Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

AsyncMap error result question #3

Closed
dannycoates opened this Issue · 2 comments

2 participants

@dannycoates

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
Owner

Yep, that's a bug.

@isaacs
Owner

Closed by 5846d8e typo

@isaacs isaacs referenced this issue from a commit
@isaacs isaacs bump version for GH-3 typo 7cc9247
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.