From 21de89608e0a285a2f880f18067c6da808ba320d Mon Sep 17 00:00:00 2001 From: Subhash Chandra Date: Wed, 15 Jan 2020 17:45:26 +0530 Subject: [PATCH 1/2] Added multiplex mode to merge Even though it theoretically supports multiple inputs and outputs, more common use case is with one of the inputs having single item similar to an iterative set node. --- packages/nodes-base/nodes/Merge.node.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/packages/nodes-base/nodes/Merge.node.ts b/packages/nodes-base/nodes/Merge.node.ts index d63d5020a2..bdcea5ea0f 100644 --- a/packages/nodes-base/nodes/Merge.node.ts +++ b/packages/nodes-base/nodes/Merge.node.ts @@ -51,6 +51,11 @@ export class Merge implements INodeType { value: 'mergeByKey', description: 'Merges data of both inputs. The output will contain items of input 1 merged with data of input 2. Merge happens depending on a defined key.', }, + { + name: 'Multiplex', + value: 'mux', + description: 'Merges each value of one input with each value of the other input. The output will contain (m * n) items where (m) and (n) are lengths of the inputs.' + }, { name: 'Pass-through', value: 'passThrough', @@ -254,6 +259,23 @@ export class Merge implements INodeType { returnData.push(newItem); } + } else if (mode === 'mux') { + const dataInput1 = this.getInputData(0); + const dataInput2 = this.getInputData(1); + + if (!dataInput1 || !dataInput2) { + return [returnData]; + } + + let entry1: INodeExecutionData; + let entry2: INodeExecutionData; + + for (entry1 of dataInput1) { + for (entry2 of dataInput2) { + returnData.push({json: {...(entry1.json), ...(entry2.json)}}); + } + } + return [returnData]; } else if (['keepKeyMatches', 'mergeByKey', 'removeKeyMatches'].includes(mode)) { const dataInput1 = this.getInputData(0); if (!dataInput1) { From 4bf28a75a63d42700bb48eaa0c0cb5e10df9e449 Mon Sep 17 00:00:00 2001 From: Jan Oberhauser Date: Wed, 15 Jan 2020 07:53:27 -0600 Subject: [PATCH 2/2] :zap: Change value of "multiplex" mode on Merge-Node --- packages/nodes-base/nodes/Merge.node.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/nodes-base/nodes/Merge.node.ts b/packages/nodes-base/nodes/Merge.node.ts index bdcea5ea0f..eae684bae6 100644 --- a/packages/nodes-base/nodes/Merge.node.ts +++ b/packages/nodes-base/nodes/Merge.node.ts @@ -53,7 +53,7 @@ export class Merge implements INodeType { }, { name: 'Multiplex', - value: 'mux', + value: 'multiplex', description: 'Merges each value of one input with each value of the other input. The output will contain (m * n) items where (m) and (n) are lengths of the inputs.' }, { @@ -259,7 +259,7 @@ export class Merge implements INodeType { returnData.push(newItem); } - } else if (mode === 'mux') { + } else if (mode === 'multiplex') { const dataInput1 = this.getInputData(0); const dataInput2 = this.getInputData(1);