https://github.com/tmobile/node-red-contrib-differences
A Node-RED node to detect differences between two sets of data
https://github.com/tmobile/node-red-contrib-differences
node-red node-red-contrib
Last synced: about 1 year ago
JSON representation
A Node-RED node to detect differences between two sets of data
- Host: GitHub
- URL: https://github.com/tmobile/node-red-contrib-differences
- Owner: tmobile
- License: apache-2.0
- Created: 2020-05-27T17:43:42.000Z (about 6 years ago)
- Default Branch: main
- Last Pushed: 2023-01-24T02:44:57.000Z (over 3 years ago)
- Last Synced: 2025-04-28T14:07:21.446Z (about 1 year ago)
- Topics: node-red, node-red-contrib
- Language: TypeScript
- Homepage:
- Size: 445 KB
- Stars: 2
- Watchers: 8
- Forks: 2
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# node-red-contrib-differences
[](https://travis-ci.com/tmobile/node-red-contrib-differences)  [](https://www.npmjs.com/package/@tmus/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](example-flow.json).
### Complement
Input as an array:
```javascript
// "Left" (desired)
[ "gadget", "gizmo", "thingamabob" ]
// "Right" (owned)
[ "widget", "gadget" ]
// Output:
[ "gizmo", "thingamabob" ]
```
Input as an object:
```javascript
// "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:
```javascript
// "Left"
[ "widget", "gadget" ]
// "Right"
[ "gadget", "gizmo", "thingamabob" ]
// Output:
[ "gadget" ]
```
Input as an object:
```javascript
// "Left"
{ widgets: 1, gadgets: 2, whatchamacallits: 2 }
// "Right"
{ gadgets: 2, gizmos: 3, thingamabobs: 4, whatchamacallits: 3 }
// Output:
{ gadgets: 2 }
```
### Union
Input as an array:
```javascript
// "Left"
[ "widget", "gadget" ]
// "Right"
[ "gadget", "gizmo", "thingamabob" ]
// Output:
[ "gadget", "widget", "gizmo", "thingamabob" ]
```
Input as an object:
```javascript
// "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 --save
node-red
```
When you're finished with your changes, merge requests are welcome!