Created
November 5, 2018 16:14
-
-
Save mlsteele/34394144a7a4751da1a8dbbff1f329bb to your computer and use it in GitHub Desktop.
Return through esc multiple times
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{make_esc} = require "iced-error" | |
bounce = (f) -> | |
setTimeout f, 0 | |
f = ({ok}, cb) -> | |
bounce -> | |
console.log "f #{ok}" | |
if ok | |
cb null | |
else | |
cb new Error "fail" | |
main = (cb) -> | |
esc = make_esc cb | |
await | |
f {ok: true }, esc defer() | |
f {ok: false}, esc defer() | |
f {ok: false}, esc defer() | |
cb null | |
main (err) -> | |
if err? | |
console.log "err: #{err}" | |
else | |
console.log "ok" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f true | |
f false | |
err: Error: fail | |
f false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment