You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
457 B
25 lines
457 B
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);
|
|
})
|
|
;
|
|
|