-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathif.js
69 lines (69 loc) · 1.45 KB
/
if.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
module.exports = {
name: "if",
ns: "utils",
title: "IF",
description: "Accepts a value on one port and checks it against an if statement.",
phrases: {
active: "Deciding IF"
},
ports: {
input: {
value: {
type: "any",
title: "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 error port. The input value will be passed either to the Yes or No port."
}
},
output: {
error: {
type: "object",
title: "Error",
description: "Error"
},
yes: {
type: "any",
title: "Yes"
},
no: {
type: "any",
title: "No"
}
}
},
dependencies: {
npm: {
iffi: require('iffi')
}
},
fn: function _if(input, $, output, state, done, cb, on, iffi) {
var r = function() {
try {
if (iffi($.in, {
value: $.value
})) {
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
};
}
}