node-red-viseo-helper
Advanced tools
Comparing version 0.1.27 to 0.1.28
62
index.js
@@ -110,2 +110,34 @@ 'use strict'; | ||
const setContextValue = exports.setContextValue = (RED, node, data, str, value, type) => { | ||
try { | ||
if (type === "msg") { | ||
RED.util.setMessageProperty(data,str,value); | ||
return true; | ||
} | ||
else if (type === 'global' || type === 'flow') { | ||
let contextKey = RED.util.parseContextStore(str); | ||
let target = node.context()[env]; | ||
target.set(contextKey.key, value, contextKey.store, null); | ||
return true; | ||
} | ||
return false; | ||
} | ||
catch(err) { | ||
error(err); | ||
return false; | ||
} | ||
} | ||
const getContextValue = exports.getContextValue = (RED, node, data, str, type) => { | ||
try { | ||
let value = RED.util.evaluateNodeProperty(str, type, node, data, null); | ||
return value; | ||
} | ||
catch(err) { | ||
error(err); | ||
return null; | ||
} | ||
} | ||
const resolve = exports.resolve = (str, obj, def) => { | ||
@@ -151,32 +183,2 @@ if (str === undefined) return str; | ||
const setContextByString = exports.setContextByString = (RED, node, str, value, env) => { | ||
if (!env) env = 'global'; | ||
else if (env !== 'global' && env !== 'flow') error('env must be "flow" or "global"'); | ||
try { | ||
let contextKey = RED.util.parseContextStore(str); | ||
let target = node.context()[env]; | ||
return target.set(contextKey.key, value, contextKey.store, null); | ||
} | ||
catch(err) { | ||
error(err); | ||
return null; | ||
} | ||
} | ||
const getContextByString = exports.getContextByString = (RED, node, str, env) => { | ||
if (!env) env = 'global'; | ||
else if (env !== 'global' && env !== 'flow') error('env must be "flow" or "global"'); | ||
try { | ||
let contextKey = RED.util.parseContextStore(str); | ||
let target = node.context()[env] | ||
return target.get(contextKey.key, contextKey.store, null); | ||
} | ||
catch(err) { | ||
error(err); | ||
return null; | ||
} | ||
} | ||
// ------------------------------------------ | ||
@@ -183,0 +185,0 @@ // EVENT |
{ | ||
"name" : "node-red-viseo-helper", | ||
"version" : "0.1.27", | ||
"version" : "0.1.28", | ||
"description" : "Utility libarary for Node-RED", | ||
@@ -5,0 +5,0 @@ "dependencies" : { |
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
204
24461