Ad
  • Custom User Avatar

    First, Chain.run checks to see if there are any links in the chain (line 11).
    Line 12 shifts the callback array one to the left, then executes the callback that is returned.

    the first parameter is "next". It references Chain.prototype.run.bind(this, end). We could also use this.run.bind(this, end), but I wanted to be more explicit.

    The second parameter is end.

    When you don't have any more links, execute end()!

  • Custom User Avatar

    the chain.prototype.run function can be reduced to one recursive call [else: end()]. Look at my fork :-)