@tmus/node-red-contrib-differences
v1.1.1
Published
Given two array inputs, when this node is executed it will output the differences between the two arrays
Downloads
128
Readme
node-red-contrib-differences
This Node-RED node will compare two inputs, then create output based on how the inputs differ.
Output functions include:
- Complement: What's in one input, but not the other
- Intersection: What's common in both inputs
- Union: Everything from both inputs
Usage
Drag and Drop the "Differences" node onto the canvas. Set the Left
and Right
input values to the source sets, set the Function
value baed on how you want differences between the left and right sets treated, and the Output
value to the destination property.
Examples
See also example-flow.json.
Complement
Input as an array:
// "Left" (desired)
[ "gadget", "gizmo", "thingamabob" ]
// "Right" (owned)
[ "widget", "gadget" ]
// Output:
[ "gizmo", "thingamabob" ]
Input as an object:
// "Left" (desired)
{ gadgets: 2, gizmos: 3, thingamabobs: 4, whatchamacallits: 3 }
// "Right (owned)
{ widgets: 1, gadgets: 2, whatchamacallits: 2 }
// Output:
{ gizmos: 3, thingamabobs: 4, whatchamacallits: 3 }
Intersection
Input as an array:
// "Left"
[ "widget", "gadget" ]
// "Right"
[ "gadget", "gizmo", "thingamabob" ]
// Output:
[ "gadget" ]
Input as an object:
// "Left"
{ widgets: 1, gadgets: 2, whatchamacallits: 2 }
// "Right"
{ gadgets: 2, gizmos: 3, thingamabobs: 4, whatchamacallits: 3 }
// Output:
{ gadgets: 2 }
Union
Input as an array:
// "Left"
[ "widget", "gadget" ]
// "Right"
[ "gadget", "gizmo", "thingamabob" ]
// Output:
[ "gadget", "widget", "gizmo", "thingamabob" ]
Input as an object:
// "Left"
{ widgets: 1, gadgets: 2, whatchamacallits: 2 }
// "Right"
{ gadgets: 2, gizmos: 3, thingamabobs: 4, whatchamacallits: 3 }
// Output:
{ widgets: 1, gadgets: 2, gizmos: 3, thingamabobs: 4, whatchamacallits: [2, 3] }
Contribute Quick Start
Fork this repository, then:
git clone https://github.com/tmobile/node-red-contrib-differences.git
cd node-red-contrib-differences
npm run build
cd ~/.node-red
npm install <path to cloned repository> --save
node-red
When you're finished with your changes, merge requests are welcome!