diff --git a/lib/index2.js b/lib/index2.js index 6c5a250bc..cd310bdef 100644 --- a/lib/index2.js +++ b/lib/index2.js @@ -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(){} +