Sebastian is a tool for separating logic into small, manageable chunks of testable code. It builds on jQuery's awesome Deferred API.
Works as a node module, or in the browser as an AMD module or traditional jQuery plugin.
npm install sebastian
bower install sebastian
Take complex code like this example:
And turn it into something easy to read and test:
Now just test one step at a time!
Check out the examples here.
A step is comprised of:
A step should ideally do one or two things - it should not be complicated. Try to keep it short and sweet. This is especially useful if you write tests first.
If the step involves an asynchronous call, you can return a jQuery Deferred or Promise to make sure the next step in the flow doesn't execute. If you don't return a Deferred, execution of next step will begin immediately.
Values returned from upstream step are passed as arguments to downstream step. If step "one" returns "blah", the first argument to step two will be "blah".
A flow is comprised of: