Created
August 26, 2010 22:26
-
-
Save technoweenie/552381 to your computer and use it in GitHub Desktop.
Step.js ported to coffeescript, with fewer features
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
# Step( | |
# () -> redis.select 15, @ | |
# () -> redis.flushdb @ | |
# () -> redis.rpush 'fakelist', '1', @ | |
# () -> redis.rpush 'fakelist', '2', @ | |
# () -> redis.rpush 'fakelist', '3', @ | |
# () -> redis.lrange 'fakelist', 0, 1, @ | |
# (err, arr) -> | |
# console.log arr.length | |
# console.log arr[0].toString() | |
# console.log arr[1].toString() | |
# @() | |
# () -> redis.close() | |
# ) | |
Step = (queue...) -> | |
context = (args...) -> | |
if fn = queue.shift() | |
try | |
run fn, args | |
catch err | |
run fn, [err] | |
run = (fn, args) -> | |
fn.apply context, args | |
context() | |
# If the first arg exists, log it to the console, and then pass the | |
# rest of the args to the next step. | |
Step.errCheck = (err, args...) -> | |
console.log err.stack if err | |
@(args...) | |
module.exports = Step |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment