Skip to content

Instantly share code, notes, and snippets.

@jgable
Created October 25, 2012 13:48
Show Gist options
  • Save jgable/3952642 to your computer and use it in GitHub Desktop.
Save jgable/3952642 to your computer and use it in GitHub Desktop.
$.when pseudo implementation in CoffeeScript
_when = (proms..., cb) ->
def = newPromise()
promCount = proms.length
finishProm = ->
promCount--
# May be -1 here...
unless promCount > 0
def.resolve()
attachTo = (p) ->
p.then finishProm, def.reject
attachTo prom for prom in proms
def.promise()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment