mooremachine
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -150,1 +150,28 @@ // Copyright 2015 Joyent, Inc. | ||
}; | ||
/* | ||
* Wraps a conventional node callback async function up into an EventEmitter so | ||
* that it can be used as a state transition trigger. | ||
*/ | ||
FSM.wrap = function _fsmWrap(fun) { | ||
function fsm_cb_wrapper() { | ||
var args = Array.prototype.slice.call(arguments); | ||
var eve = new EventEmitter(); | ||
var cb = function () { | ||
var resArgs = Array.prototype.slice.call(arguments); | ||
var err = resArgs.shift(); | ||
if (err) { | ||
eve.emit('error', err); | ||
} else { | ||
resArgs.unshift('return'); | ||
eve.emit.apply(eve, resArgs); | ||
} | ||
}; | ||
args.push(cb); | ||
eve.run = function () { | ||
fun.apply(this, args); | ||
}; | ||
return (eve); | ||
} | ||
return (fsm_cb_wrapper); | ||
}; |
{ | ||
"name": "mooremachine", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Moore finite state machines", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6200
166