-
-
Save shesek/eff0c0abd31ad8457de8 to your computer and use it in GitHub Desktop.
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
iferr = (fail, succ) -> (err, a...) -> if err? then fail err else succ a... | |
# example | |
foo = (cb) -> | |
fs.readFile something, iferr cb, (contents) -> | |
# yey, no need to `return cb err if err?` all over the place | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Javascript version: