-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathif2.js
75 lines (75 loc) · 1.57 KB
/
if2.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
module.exports = {
name: "if2",
ns: "utils",
title: "IF2",
description: "Accepts values on two ports and checks it against an if statement.",
phrases: {
active: "Deciding IF"
},
ports: {
input: {
value: {
type: "any",
title: "Input Value",
description: "The value to be checked"
},
compare: {
type: "any",
title: "Comparant Value"
},
"in": {
type: "string",
title: "IF statement",
description: "Any if statement, the input is available as `in`. e.g. in.required === true, providing the input object has a property `required`, compilation failures will go to the output port."
}
},
output: {
error: {
type: "object",
title: "Error",
description: "Error"
},
yes: {
type: "boolean",
title: "Yes"
},
no: {
type: "boolean",
title: "No"
}
}
},
dependencies: {
npm: {
iffi: require('iffi')
}
},
fn: function if2(input, $, output, state, done, cb, on, iffi) {
var r = function() {
try {
if (iffi($.in, {
'value': $.value,
'compare': $.compare
})) {
output = {
yes: $.create($.value)
};
} else {
output = {
no: $.create($.value)
};
}
} catch (e) {
output = {
error: $.create(e)
};
}
}.call(this);
return {
output: output,
state: state,
on: on,
return: r
};
}
}