node-red-contrib-prib-functions
Advanced tools
Comparing version 0.14.2 to 0.16.0
@@ -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": |
{ | ||
"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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 3 instances in 1 package
1293897
7
66
4924
1
313
+ Addedadler-32@1.2.0(transitive)
+ Addedcodepage@1.14.0(transitive)
+ Addedcommander@2.14.12.17.1(transitive)
+ Addedexit-on-epipe@1.0.1(transitive)
+ Addedfast-xml-parser@3.21.1(transitive)
+ Addedfflate@0.3.11(transitive)
+ Addednode-red-contrib-logger@0.0.6(transitive)
+ Addedprintj@1.1.2(transitive)
+ Addedxlsx@0.16.9(transitive)
- Removedcodepage@1.15.0(transitive)
- Removedfast-xml-parser@4.5.0(transitive)
- Removednode-red-contrib-logger@0.0.4(transitive)
- Removedxlsx@0.18.5(transitive)
Updatedavsc@^5.6.1
Updatedfast-xml-parser@^3.19.0
Updatedxlsx@^0.16.9