-
Notifications
You must be signed in to change notification settings - Fork 17
/
Output.js
47 lines (41 loc) · 1.08 KB
/
Output.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
const noflo = require('noflo');
const { inspect } = require('util');
const log = (options, data) => {
if (options != null) {
return console.log(inspect(
data,
options.showHidden,
options.depth,
options.colors,
));
}
return console.log(data);
};
exports.getComponent = () => {
const c = new noflo.Component();
c.description = 'Sends the data items to console.log';
c.icon = 'bug';
c.inPorts.add('in', {
datatype: 'all',
description: 'Packet to be printed through console.log',
});
c.inPorts.add('options', {
datatype: 'object',
description: 'Options to be passed to console.log',
control: true,
});
c.outPorts.add('out', {
datatype: 'all',
});
return c.process((input, output) => {
if (!input.hasData('in')) { return; }
if (input.attached('options').length && !input.hasData('options')) { return; }
let options = null;
if (input.has('options')) {
options = input.getData('options');
}
const data = input.getData('in');
log(options, data);
output.sendDone({ out: data });
});
};