diff options
author | isaacs <i@izs.me> | 2020-07-24 22:50:02 +0300 |
---|---|---|
committer | isaacs <i@izs.me> | 2020-07-29 21:55:03 +0300 |
commit | bbe4279120c94791b70d97f235c73d972fd67354 (patch) | |
tree | a098e008fc4b906180a4b5ca03a6203ba7a946d5 /node_modules/fast-deep-equal/index.js | |
parent | 764103ceff2ec2e80f396b5a071660fd7425be15 (diff) |
reset and update all deps
Diffstat (limited to 'node_modules/fast-deep-equal/index.js')
-rw-r--r-- | node_modules/fast-deep-equal/index.js | 59 |
1 files changed, 25 insertions, 34 deletions
diff --git a/node_modules/fast-deep-equal/index.js b/node_modules/fast-deep-equal/index.js index 7aaaba3f6..30dd1ba78 100644 --- a/node_modules/fast-deep-equal/index.js +++ b/node_modules/fast-deep-equal/index.js @@ -1,55 +1,46 @@ 'use strict'; -var isArray = Array.isArray; -var keyList = Object.keys; -var hasProp = Object.prototype.hasOwnProperty; +// do not edit .js files directly - edit src/index.jst + + module.exports = function equal(a, b) { if (a === b) return true; - var arrA = isArray(a) - , arrB = isArray(b) - , i - , length - , key; - - if (arrA && arrB) { - length = a.length; - if (length != b.length) return false; - for (i = 0; i < length; i++) - if (!equal(a[i], b[i])) return false; - return true; - } + if (a && b && typeof a == 'object' && typeof b == 'object') { + if (a.constructor !== b.constructor) return false; + + var length, i, keys; + if (Array.isArray(a)) { + length = a.length; + if (length != b.length) return false; + for (i = length; i-- !== 0;) + if (!equal(a[i], b[i])) return false; + return true; + } - if (arrA != arrB) return false; - var dateA = a instanceof Date - , dateB = b instanceof Date; - if (dateA != dateB) return false; - if (dateA && dateB) return a.getTime() == b.getTime(); - var regexpA = a instanceof RegExp - , regexpB = b instanceof RegExp; - if (regexpA != regexpB) return false; - if (regexpA && regexpB) return a.toString() == b.toString(); + if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags; + if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf(); + if (a.toString !== Object.prototype.toString) return a.toString() === b.toString(); - if (a instanceof Object && b instanceof Object) { - var keys = keyList(a); + keys = Object.keys(a); length = keys.length; + if (length !== Object.keys(b).length) return false; - if (length !== keyList(b).length) - return false; + for (i = length; i-- !== 0;) + if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false; - for (i = 0; i < length; i++) - if (!hasProp.call(b, keys[i])) return false; + for (i = length; i-- !== 0;) { + var key = keys[i]; - for (i = 0; i < length; i++) { - key = keys[i]; if (!equal(a[key], b[key])) return false; } return true; } - return false; + // true if both NaN, false otherwise + return a!==a && b!==b; }; |