@node-red/util
Advanced tools
Comparing version 2.2.0 to 2.2.1
@@ -70,4 +70,21 @@ const Log = require("./log.js"); | ||
// Get location of calling code | ||
let callModule; | ||
const stack = new Error().stack; | ||
const callModule = stack.split("\n")[2].split("(")[1].slice(0,-1); | ||
const stackEntries = stack.split("\n").slice(1);//drop 1st line (error message) | ||
const stackEntry2 = stackEntries[1];//get 2nd stack entry | ||
if (stackEntry2) { | ||
try { | ||
if (stackEntry2.indexOf(" (") >= 0) { | ||
callModule = stackEntry2.split("(")[1].slice(0, -1); | ||
} else { | ||
callModule = stackEntry2.split(" ").slice(-1)[0]; | ||
} | ||
} catch (error) { | ||
Log.debug(`Unable to determined module when adding hook '${hookId}'. Stack:\n${stackEntries.join("\n")}`); | ||
callModule = "unknown:0:0"; | ||
} | ||
} else { | ||
Log.debug(`Unable to determined module when adding hook '${hookId}'. Stack:\n${stackEntries.join("\n")}`); | ||
callModule = "unknown:0:0"; | ||
} | ||
Log.debug(`Adding hook '${hookId}' from ${callModule}`); | ||
@@ -74,0 +91,0 @@ |
@@ -27,4 +27,15 @@ /** | ||
const util = require("util"); | ||
const { hasOwnProperty } = Object.prototype; | ||
/** | ||
* Safely returns the object construtor name. | ||
* @return {String} the name of the object constructor if it exists, empty string otherwise. | ||
*/ | ||
function constructorName(obj) { | ||
// Note: This function could be replaced by optional chaining in Node.js 14+: | ||
// obj?.constructor?.name | ||
return obj && obj.constructor ? obj.constructor.name : ''; | ||
} | ||
/** | ||
* Generates a psuedo-unique-random id. | ||
@@ -175,3 +186,3 @@ * @return {String} a random-ish id | ||
/* istanbul ignore else */ | ||
if (obj1.hasOwnProperty(k)) { | ||
if (hasOwnProperty.call(obj1, k)) { | ||
if (!compareObjects(obj1[k],obj2[k])) { | ||
@@ -467,3 +478,3 @@ return false; | ||
if (typeof key === 'string' || (typeof key === 'number' && !Array.isArray(obj))) { | ||
if (obj.hasOwnProperty(key)) { | ||
if (hasOwnProperty.call(obj, key)) { | ||
if (length > 1 && ((typeof obj[key] !== "object" && typeof obj[key] !== "function") || obj[key] === null)) { | ||
@@ -567,3 +578,3 @@ // Break out early as we cannot create a property beneath | ||
function evaluateEnvProperty(value, node) { | ||
var flow = (node && node.hasOwnProperty("_flow")) ? node._flow : null; | ||
var flow = (node && hasOwnProperty.call(node, "_flow")) ? node._flow : null; | ||
var result; | ||
@@ -792,3 +803,3 @@ if (/^\${[^}]+}$/.test(value)) { | ||
var debuglength = 1000; | ||
if (opts && opts.hasOwnProperty('maxLength')) { | ||
if (opts && hasOwnProperty.call(opts, 'maxLength')) { | ||
debuglength = opts.maxLength; | ||
@@ -803,3 +814,3 @@ } | ||
} | ||
if (msg.msg.hasOwnProperty('message')) { | ||
if (hasOwnProperty.call(msg.msg, 'message')) { | ||
errorMsg.message = msg.msg.message; | ||
@@ -818,3 +829,3 @@ } else { | ||
try { | ||
msg.format = msg.msg.constructor.name || "Object"; | ||
msg.format = constructorName(msg.msg) || "Object"; | ||
// Handle special case of msg.req/res objects from HTTP In node | ||
@@ -846,3 +857,3 @@ if (msg.format === "IncomingMessage" || msg.format === "ServerResponse") { | ||
} | ||
} else if (msg.msg && msg.msg.constructor.name === "Set") { | ||
} else if (constructorName(msg.msg) === "Set") { | ||
msg.format = "set["+msg.msg.size+"]"; | ||
@@ -856,3 +867,3 @@ msg.msg = { | ||
needsStringify = true; | ||
} else if (msg.msg && msg.msg.constructor.name === "Map") { | ||
} else if (constructorName(msg.msg) === "Map") { | ||
msg.format = "map"; | ||
@@ -866,3 +877,3 @@ msg.msg = { | ||
needsStringify = true; | ||
} else if (msg.msg && msg.msg.constructor.name === "RegExp") { | ||
} else if (constructorName(msg.msg) === "RegExp") { | ||
msg.format = 'regexp'; | ||
@@ -917,7 +928,7 @@ msg.msg = msg.msg.toString(); | ||
} | ||
} else if (value.constructor.name === "ServerResponse") { | ||
} else if (constructorName(value) === "ServerResponse") { | ||
value = "[internal]" | ||
} else if (value.constructor.name === "Socket") { | ||
} else if (constructorName(value) === "Socket") { | ||
value = "[internal]" | ||
} else if (value.constructor.name === "Set") { | ||
} else if (constructorName(value) === "Set") { | ||
value = { | ||
@@ -929,3 +940,3 @@ __enc__: true, | ||
} | ||
} else if (value.constructor.name === "Map") { | ||
} else if (constructorName(value) === "Map") { | ||
value = { | ||
@@ -937,3 +948,3 @@ __enc__: true, | ||
} | ||
} else if (value.constructor.name === "RegExp") { | ||
} else if (constructorName(value) === "RegExp") { | ||
value = { | ||
@@ -990,3 +1001,3 @@ __enc__: true, | ||
} | ||
if (e.hasOwnProperty('message')) { | ||
if (hasOwnProperty.call(e, 'message')) { | ||
errorMsg.message = 'encodeObject Error: ['+e.message + '] Value: '+util.inspect(msg.msg); | ||
@@ -993,0 +1004,0 @@ } else { |
{ | ||
"name": "@node-red/util", | ||
"version": "2.2.0", | ||
"version": "2.2.1", | ||
"license": "Apache-2.0", | ||
@@ -19,5 +19,5 @@ "repository": { | ||
"fs-extra": "10.0.0", | ||
"i18next": "21.6.10", | ||
"i18next": "21.6.11", | ||
"json-stringify-safe": "5.0.1", | ||
"jsonata": "1.8.5", | ||
"jsonata": "1.8.6", | ||
"lodash.clonedeep": "^4.5.0", | ||
@@ -24,0 +24,0 @@ "moment-timezone": "0.5.34" |
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
75788
1866
+ Addedi18next@21.6.11(transitive)
+ Addedjsonata@1.8.6(transitive)
- Removedi18next@21.6.10(transitive)
- Removedjsonata@1.8.5(transitive)
Updatedi18next@21.6.11
Updatedjsonata@1.8.6