-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
50 lines (40 loc) · 906 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//Get process steps.
const {
typeLength,
match,
execFn,
parameters,
output
} = require('./steps');
//Middleware process function.
const {processate} = require('./process.js');
/*
Decorate internal steps
1) validate types length with parameters length
2) match structure types with parameters structure and get the param+value struct.
3) validate both structure using new typedefs.
4) Call function
5) If there are a function type return defined, validate and if the type is ok return it.
*/
const decorate = (types,out) => (fn)=>(...args)=>{
//Functions data to be processed in the steps.
let base = {
types,
out,
fn,
args,
result : null
};
//Processate the steps and return the stack.
const fnStack = processate(base,[
typeLength,
match,
parameters,
execFn,
output
]);
return fnStack;
}
module.exports = {
decorate
}