synx
v0.0.4
Published
### Synx allows you to quickly abstract over values which may be provided by synchronously, with callbacks or via promises ###
Downloads
3
Readme
Synx
Synx allows you to quickly abstract over values which may be provided by synchronously, with callbacks or via promises
How to use synx
On the command line:
> npm install synx --save
To run tests:
> gulp test
To build for the browser (WIP)
> gulp bundle
In your application
var synx = require('synx');
Usage:
#!javascript
var aStack = synx(); // Create a new stack definition
synx('namedStack'); // Create a 'named' stack definition
synx()
// An async function, node style callback with synx.$cb -> err, result
.do(function(cb) {
cb(null, 'resolveValue');
}, synx.$cb)
// A function which returns a promise
.do(promiseReturningFunction)
// A function which returns a value
.do(syncFunction, synx.$prev) // Previously resolved value
// A stack definition
.do(aStack)
// A named stack definition
.do('namedStack');
// any command which returns a bool here
.if( ... )
.do( ... )
.do( ... )
.end()
// Return a value to check against
.switch( ... )
// Check the value
.case( ... )
.do ( ... )
.do ( ... )
.case( ... )
.do ( ... )
.do ( ... )
.end()
var stackExectution = stackDefinition.execute(valueOne, valueTwo);
stackExecution
.onComplete(alwaysCallback)
.onSuccess(successCallback)
.onError(errorCallback);
ToDo:
[ ] Series / Parallel
[ ] Util Functions