fsig
v1.0.0
Published
A utility that allows functions to send signals to the executer.
Downloads
2
Readme
sig
A utility that allows functions to send signals to executers.
Installation
$ npm install sig
Usage
const sig = require("fsig");
function* test() {
yield "a";
yield "b";
yield "c";
return "d";
}
console.log("returns:", sig(test).catch(x => {
console.log("catch:", x);
}).onSignal(x => { // synonym of .catch
console.log("onSignal:", x);
}).start());
// catch: a
// onSignal: a
// catch: b
// onSignal: b
// catch: c
// onSignal: c
// returns: d
console.log(sig(test).emitter);
// EventEmitter {}
var s = sig(test);
s.emitter.on("signal", function(x) {
console.log(x)
});
console.log("returns:", s.start());
// a
// b
// c
// returns: d
License
MIT License.