-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathConcat.js
More file actions
28 lines (27 loc) · 837 Bytes
/
Concat.js
File metadata and controls
28 lines (27 loc) · 837 Bytes
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
const noflo = require('noflo');
exports.getComponent = () => {
const c = new noflo.Component();
c.description = 'Gathers data from all incoming connections and sends them together in order of connection';
c.inPorts.add('in', {
datatype: 'all',
addressable: true,
});
c.outPorts.add('out',
{ datatype: 'all' });
return c.process((input, output) => {
const indexesWithStreams = input.attached('in').filter((idx) => input.hasStream(['in', idx]));
if (indexesWithStreams.length !== input.attached('in').length) { return; }
indexesWithStreams.forEach((idx) => {
const stream = input.getStream(['in', idx]);
stream.forEach((packet) => {
output.send({
out: {
...packet,
index: idx,
},
});
});
});
output.done();
});
};