const {contains, curry, filter, forEach, pluck} = require('ramda');
const asArray = require('./asArray');

module.exports = curry((virtualNode, destination) => {
  if (virtualNode.isCustomVirtualNode) {
    const outputVirtualNodes = filter(({output}) => contains('output', asArray(output)), virtualNode.virtualNodes);
    forEach((audioNode) => audioNode.connect(destination), pluck('audioNode', outputVirtualNodes));
  } else {
    virtualNode.audioNode.connect(destination);
  }
  virtualNode.connected = true;
});

@@ -21,30 +21,14 @@
 ry, 
-filter, forEach, pluck
+mapObj
 %7D = 
@@ -180,16 +180,51 @@
 Node) %7B%0A
+    mapObj(childVirtualNode =%3E %7B%0A  
     cons
@@ -225,22 +225,32 @@
   const 
+%7B
 output
+%7D = child
 VirtualN
@@ -256,33 +256,20 @@
 Node
-s = filter((%7Boutput%7D) =%3E 
+;%0A      if (
 cont
@@ -303,122 +303,97 @@
 ut))
-, virtualNode.virtualNodes);%0A    forEach((audioNode) =%3E audioNode.connect(destination), pluck('audioNode', outputV
+) %7B%0A        childVirtualNode.audioNode.connect(destination);%0A      %7D%0A    %7D, virtualNode.v
 irtu
@@ -400,17 +400,16 @@
 alNodes)
-)
 ;%0A  %7D el

update src