compose function

This commit is contained in:
Austen Collins 2015-10-13 02:31:57 -07:00
parent c3f9396a5f
commit 84bd16d4a2

View File

@ -10,6 +10,7 @@ const path = require('path'),
/**
* JAWS Class
*/
let JAWS = class JAWS {
constructor() {
@ -107,6 +108,7 @@ let JAWS = class JAWS {
* Update Config
* @param config
*/
config(config) {
// Extend JAWS with config properties
@ -116,6 +118,7 @@ let JAWS = class JAWS {
/**
* Set Action
*/
action(action, actionGenerator) {
// Check action is valid
@ -129,6 +132,7 @@ let JAWS = class JAWS {
/**
* Set Hook
*/
hook(hook, hookGenerator, index) {
// Check hook is valid
@ -141,13 +145,26 @@ let JAWS = class JAWS {
}
/**
* Orchestrator
* Compose
*/
orchestrate() {
compose(genArray) {
return function *(next){
if (!next) next = noop();
var i = genArray.length;
while (i--) {
next = genArray[i].call(this, next);
}
yield *next;
}
}
}
module.exports = new JAWS();
function *noop(){}