1.0.0 • Published 5 years ago

fsig v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

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.

1.0.0

5 years ago