Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@steveorevo/node-red-emerge

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@steveorevo/node-red-emerge - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

74

emerge/emerge.js

@@ -5,2 +5,31 @@ module.exports = function(RED) {

var node = this;
// Access nested objects
const getNestedObject = (nestedObj, pathArr) => {
return pathArr.split('.').reduce((obj, key) =>
(obj && obj[key] !== 'undefined') ? obj[key] : undefined, nestedObj);
}
// String manipulation functions
String.prototype.delLeftMost = function (sFind) {
for (var i = 0; i < this.length; i = i + 1) {
var f = this.indexOf(sFind, i);
if (f != -1) {
return this.substring(f + sFind.length, f + sFind.length + this.length);
break;
}
}
return this;
};
String.prototype.getLeftMost = function (sFind) {
for (var i = 0; i < this.length; i = i + 1) {
var f = this.indexOf(sFind, i);
if (f != -1) {
return this.substring(0, f);
break;
}
}
return this;
};
node.on('input', function(msg, send, done) {

@@ -19,2 +48,3 @@

let rulePass = false;
if (config.grpRules == undefined) return;
for (let i = 0; i < config.grpRules.length; i++) {

@@ -24,2 +54,3 @@ let r = config.grpRules[i];

let globalContext = node.context().global;
rulePass = false;

@@ -30,11 +61,26 @@ // Get the property value to compare

case "msg":
rulePropertyValue = msgBuffer[r.ruleProperty];
rulePropertyValue = getNestedObject(msgBuffer, r.ruleProperty);
break;
case "flow":
rulePropertyValue = flowContext.get(r.ruleProperty);
if (r.ruleProperty.indexOf(".") == -1) {
rulePropertyValue = flowContext.get(r.ruleProperty);
}else{
let parent = r.ruleProperty.getLeftMost('.');
let offspring = r.ruleProperty.delLeftMost('.');
rulePropertyValue = flowContext.get(parent);
rulePropertyValue = getNestedObject(rulePropertyValue, offspring);
}
break;
case "global":
rulePropertyValue = globalContext.get(r.ruleProperty);
if (r.ruleProperty.indexOf(".") == -1) {
rulePropertyValue = globalContext.get(r.ruleProperty);
} else {
let parent = r.ruleProperty.getLeftMost('.');
let offspring = r.ruleProperty.delLeftMost('.');
rulePropertyValue = globalContext.get(parent);
rulePropertyValue = getNestedObject(rulePropertyValue, offspring);
}
break;
}
if (rulePropertyValue == undefined) break;

@@ -45,9 +91,23 @@ // Get the comparative rule value

case "msg":
ruleCompareValue = msgBuffer[r.ruleValue];
ruleCompareValue = getNestedObject(msgBuffer, r.ruleValue);
break;
case "flow":
ruleCompareValue = flowContext.get(r.ruleValue);
if (r.ruleValue.indexOf(".") == -1) {
ruleCompareValue = flowContext.get(r.ruleValue);
}else{
let parent = r.ruleValue.getLeftMost('.');
let offspring = r.ruleValue.delLeftMost('.');
ruleCompareValue = flowContext.get(parent);
ruleCompareValue = getNestedObject(ruleCompareValue, offspring);
}
break;
case "global":
ruleCompareValue = globalContext.get(r.ruleValue);
if (r.ruleValue.indexOf(".") == -1) {
ruleCompareValue = globalContext.get(r.ruleValue);
} else {
let parent = r.ruleValue.getLeftMost('.');
let offspring = r.ruleValue.delLeftMost('.');
ruleCompareValue = globalContext.get(parent);
ruleCompareValue = getNestedObject(ruleCompareValue, offspring);
}
break;

@@ -64,5 +124,5 @@ case "str":

}
if (ruleCompareValue == undefined) break;
// Do the comparative logic
rulePass = false;
switch(r.ruleOperation) {

@@ -69,0 +129,0 @@ case "==":

31

package.json
{
"name": "@steveorevo/node-red-emerge",
"version": "1.0.0",
"version": "1.1.0",
"description": "A node that merges msg objects until all defined properties are present / conditions met before passing the combined msg along.",
"author": "Stephen J. Carnam <steveorevo@gmail.com>",
"license": "MIT",
"keywords": ["node-red","merge", "await", "join", "combine", "wait"],
"keywords": [
"node-red",
"merge",
"await",
"join",
"combine",
"wait"
],
"repository": {
"type": "git",
"url": "https://github.com/steveorevo/node-red-emerge.git"
"type": "git",
"url": "https://github.com/steveorevo/node-red-emerge.git"
},
"dependencies": {
"dependencies": {},
"node-red": {
"nodes": {
"emerge": "emerge/emerge.js"
},
"version": ">=3.0.0"
},
"node-red": {
"nodes": {
"emerge": "emerge/emerge.js"
}
"engines": {
"node": ">=14.0.0"
}
}
}

@@ -5,6 +5,6 @@ # node-red-contrib-emerge

### Use case scenario
Often times we need to submit a msg to a node with various properties present and filled out; these properties may come from various asynchronous and parallel flow segments. Counting messages and waiting to gather all these values into a single msg can be a burden. The emerge node can simplify that burden be combining msgs until all the needed properties are present and/or meet the conditional requirements before passing the message along.
Often times we need to submit a msg to a node with various properties present and filled out; these properties may come from various asynchronous and parallel flow segments. Counting messages and waiting to gather all these values into a single msg can by a burden. The emerge node can simplify that burden be combining msgs until all the needed properties are present and/or meet the conditional requirements before passing the message along.
### How to install
You can install emerge via [Node-RED's built in palette manager](https://nodered.org/docs/user-guide/editor/palette/manager) and searching for @Steveorevo/node-red-emerge
You can install emerge via [Node-RED's built in palette manager](https://nodered.org/docs/user-guide/editor/palette/manager) and searching for `node-red-emerge`

@@ -11,0 +11,0 @@ or

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc