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
# Lean and Mean Serial DSL for CoffeeScript | |
# (based of https://gist.github.com/1090670 by timcameronryan) | |
serial = (spec) -> | |
commands = (func for key, func of spec when key != 'catch') | |
next = (err, args...) -> | |
return spec.catch(err) if err | |
commands.shift().apply(next, args) if commands.length > 0 | |
next null | |
return |