UNPKG

719 Btext/coffeescriptView Raw
1noflo = require 'noflo'
2owl = require 'owl-deepcopy'
3
4# @runtime noflo-nodejs
5
6class Copy extends noflo.Component
7 description: 'deep (i.e. recursively) copy an object'
8 icon: 'copy'
9
10 constructor: ->
11 @inPorts = new noflo.InPorts
12 in:
13 datatype: 'all'
14 description: 'Packet to be copied'
15 @outPorts = new noflo.OutPorts
16 out:
17 datatype: 'all'
18
19 @inPorts.in.on 'begingroup', (group) =>
20 @outPorts.out.beginGroup group
21
22 @inPorts.in.on 'data', (data) =>
23 @outPorts.out.send owl.deepCopy data
24
25 @inPorts.in.on 'endgroup', =>
26 @outPorts.out.endGroup()
27
28 @inPorts.in.on 'disconnect', =>
29 @outPorts.out.disconnect()
30
31exports.getComponent = -> new Copy