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

node-red-contrib-prib-functions

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-red-contrib-prib-functions - npm Package Compare versions

Comparing version 0.14.2 to 0.16.0

.github/workflows/codeql-analysis.yml

19

dataAnalysis/dataAnalysis.js

@@ -269,7 +269,19 @@ const logger = new (require("node-red-contrib-logger"))("Data Analysis");

},
sampleVariance:(d)=>{
const mean=functions.avg(d);
const sum=functions.sumWithFunction(d,(v)=>v-mean)
return sum/(d.length-1)
},
sum:(d)=>d.reduce((p,c)=>p+c),
sumWithFunction:(d,f)=>d.reduce((p,c)=>p+f.apply(this,[c]),0),
variance:(d)=>{ //Var(X) = E (X − E(X))2 = E(X2) − (E(X))2
return functions.sumWithFunction(d,(v)=>Math.pow(v,2))
- Math.pow(functions.avg(d),2);
const n=d.length;
return functions.sumWithFunction(d,(v)=>Math.pow(v,2))/n - Math.pow(functions.avg(d),2);
},
sampleStdDev:(d)=>Math.sqrt(functions.sampleVariance(d)),
sampleVariance:(d)=>{
if(d.length<2)return 0
const mean=functions.avg(d);
const sum=d.reduce((a,e)=>a+Math.pow(e-mean,2),0);
return sum/(d.length-1)
}

@@ -365,3 +377,4 @@ }

try{
msg.result=node.actionfunction.apply(node,[node.getData(msg,node),node.term,node]);
const data=node.getData(msg,node);
if(data) msg.result=node.actionfunction.apply(node,[data,node.term,node]);
switch(node.action) {

@@ -368,0 +381,0 @@ case "realtime":

36

package.json
{
"name": "node-red-contrib-prib-functions",
"version": "0.14.2",
"version": "0.16.0",
"description": "Node-RED added node functions.",
"dependencies": {
"node-red-contrib-logger": "0.0.4",
"avsc": "*",
"fast-xml-parser": "*",
"xlsx": "*"
"avsc": "^5.6.1",
"fast-xml-parser": "^3.19.0",
"node-red-contrib-logger": "^0.0.6",
"xlsx": "^0.16.9"
},
"devDependencies": {
"bl": ">=1.2.3",
"bcrypt": ">=5.0.0",
"eslint": "^6.8.0",
"eslint-config-standard": "^14.1.0",
"eslint-plugin-import": "^2.19.1",
"eslint-plugin-mocha": "^8.0.0",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.1",
"mocha": "^8.1.3",
"node-red": "^1.1.3",
"node-red-node-test-helper": "*"
"@node-red/runtime": ">=1.2.8",
"axios": ">=0.21.1",
"bcrypt": "^5.0.1",
"bl": "^5.0.0",
"mocha": "^8.3.2",
"node-red": "^1.3.1",
"node-red-node-test-helper": "^0.2.7"
},
"scripts": {
"test": "mocha \"test/**/*.js\"",
"lint": "eslint --ext .js ./",
"lint-fix": "eslint --fix --ext .js ./"
"test": "mocha \"test/**/*.js\""
},

@@ -64,2 +57,3 @@ "repository": {

"minimun",
"model",
"monitor",

@@ -74,2 +68,4 @@ "moving",

"realtime",
"sample variance",
"sample stddev",
"Simple Moving Average",

@@ -76,0 +72,0 @@ "skew",

@@ -245,2 +245,4 @@ # [node-red-contrib-prib-functions][2]

0.16.0 fix data analysis variance and stddev, add sample, add tests
0.14.2 fix general test flows. Add icon for data analysis

@@ -247,0 +249,0 @@

@@ -32,3 +32,3 @@ const logger = new (require("node-red-contrib-logger"))("test").sendInfo("Copyright 2020 Jaroslav Peter Prib");

function equalObjects(obj1,obj2) {
function equalObjects(obj1,obj2,errorFactor) {
if( obj1 === obj2 ) return true;

@@ -38,3 +38,5 @@ if( obj1 === Number.POSITIVE_INFINITY && obj2==="Infinity") return true;

if( Number.isNaN(obj1) && obj2==="NaN") return true;
if( typeof obj1 != typeof obj2 ) return false;
const obj1type=typeof obj1;
if( obj1type != typeof obj2 ) return false;
if(errorFactor && obj1type=="number") return (Math.abs(obj2-obj1)/obj2)<errorFactor;
if( !(obj1 instanceof Object) ) return false;

@@ -44,3 +46,3 @@ if( Object.keys(obj1).length !== Object.keys(obj2).length ) return false;

for(let key in obj1) {
if( !equalObjects(obj1[key],obj2[key]) ) return false;
if( !equalObjects(obj1[key],obj2[key],errorFactor) ) return false;
}

@@ -75,3 +77,3 @@ } catch(e) {

setError(msg,node,"Sent by another test "+msg._test.id);
} else if(!equalObjects(node.getData(msg,node),msg._test.result)) {
} else if(!equalObjects(node.getData(msg,node),msg._test.result,node.errorFactor)) {
msg._test.testedValue=node.getData(msg,node);

@@ -78,0 +80,0 @@ setError(msg,node,"Test failed");

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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