mirror of
https://github.com/serverless/serverless.git
synced 2026-01-25 15:07:39 +00:00
compose function
This commit is contained in:
parent
c3f9396a5f
commit
84bd16d4a2
@ -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(){}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user