mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
permit non strict comparison of string or number
This commit is contained in:
parent
84a9cf7adf
commit
10f77fdf1a
@ -139,17 +139,23 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
/**
|
/**
|
||||||
* Compares `v1` with `v2` for equality
|
* Compares `newValue` with `originalValue` for equality.
|
||||||
* @param {*} v1 variable 1
|
* NOTES:
|
||||||
* @param {*} v2 variable 2
|
* * If `newValue` is a string or number, comparison is not strict
|
||||||
* @returns {boolean} true if variable 1 equals variable 2, otherwise false
|
* * If `newValue` is anything else, comparison is strict
|
||||||
|
* @param {*} originalValue Original value
|
||||||
|
* @param {*} newValue New value
|
||||||
|
* @returns {boolean} true if originalValue equals newValue, otherwise false
|
||||||
*/
|
*/
|
||||||
function isEqual(v1, v2) {
|
function isEqual(originalValue, newValue) {
|
||||||
try {
|
try {
|
||||||
if(v1 === v2) {
|
if (typeof newValue === "string" || typeof newValue === "number") {
|
||||||
return true;
|
return originalValue == newValue;
|
||||||
}
|
}
|
||||||
return JSON.stringify(v1) === JSON.stringify(v2);
|
if (typeof newValue === "boolean") {
|
||||||
|
return originalValue === newValue;
|
||||||
|
}
|
||||||
|
return JSON.stringify(originalValue) === JSON.stringify(newValue);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user