mirror of
https://github.com/gradle/gradle-build-action.git
synced 2024-11-23 16:51:04 -05:00
26 lines
457 B
JavaScript
26 lines
457 B
JavaScript
|
var Chainsaw = require('chainsaw');
|
||
|
|
||
|
function AddDo (sum) {
|
||
|
return Chainsaw(function (saw) {
|
||
|
this.add = function (n) {
|
||
|
sum += n;
|
||
|
saw.next();
|
||
|
};
|
||
|
|
||
|
this.do = function (cb) {
|
||
|
saw.nest(cb, sum);
|
||
|
};
|
||
|
});
|
||
|
}
|
||
|
|
||
|
AddDo(0)
|
||
|
.add(5)
|
||
|
.add(10)
|
||
|
.do(function (sum) {
|
||
|
if (sum > 12) this.add(-10);
|
||
|
})
|
||
|
.do(function (sum) {
|
||
|
console.log('Sum: ' + sum);
|
||
|
})
|
||
|
;
|