Breeze
Functional async flow control library.
![Dependencies](https://img.shields.io/david/Nijikokun/breeze.svg?style=flat)
Install
Usage
Node.js / Browserify
var breeze = require('breeze')
API
breeze(next)
- Initialize breeze flow system, supports initial .then
method..when(arg, next)
- When arg
is truthy, add next
to the stack.maybe(arg, next)
- When arg
is truthy, add next
to the stack, sugar for breeze.when
.some(arg, next)
- When arg
is truthy and no other some
or none
has ran, add to the stack.none(next)
- Whenever no some
have ran, add callback to the stack.then(next)
- Add callback to stack.catch(next)
- Any error caught will terminate stack and be sent here.reset()
- Reset current system
Example
breeze(function (done) {
done()
})
.maybe(1 === 1, function (done) {
console.log(1)
done(null, 'hey,', 'you can pass values!')
})
.some(function (part1, part2) {
return 1 === 0
}, function (done, msg) {
console.log(2, msg)
done()
})
.none(function (done, part1, part2) {
console.log(2, ',since no some happened,', part1, part2)
done()
})
.then(function (done) {
console.log(3)
done('It finally happened.')
})
.catch(function (err) {
console.error('An error occurred!', err)
})
License
Licensed under The MIT License.