Skip to content

Instantly share code, notes, and snippets.

@audreyt
Created December 28, 2013 17:17
Show Gist options
  • Save audreyt/8161697 to your computer and use it in GitHub Desktop.
Save audreyt/8161697 to your computer and use it in GitHub Desktop.
Q = require \q
p = [1 2 3]
q = [4 5 6]
(.reduce Q.when, Q!) <| for let i in p => ->
<- Q.delay 500ms .then
console.log i
(.reduce Q.when, Q!) <| for let j in q => ->
<- Q.delay 500ms .then
console.log i, j
@audreyt
Copy link
Author

audreyt commented Dec 28, 2013

{delay}:Q = require \q
p = [1 2 3]
q = [4 5 6]
each = (xs, f) -> xs.map((x) -> -> f x).reduce Q.when, Q!
each p, (i) ->
  console.log i
  <- delay 500ms .then
  each q, (j) ->
    console.log i, j
    <- delay 500ms .then

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment