mirror of
https://github.com/nodejs/node.git
synced 2025-05-15 04:53:30 +00:00

We have been stalled on ESLint 3.8.0 for some time. Current ESLint is 3.13.0. We have been unable to upgrade because of more aggressive reporting on some rules, including indentation. ESLint configuration options and bugfixes are now such that we can reasonably upgrade. PR-URL: https://github.com/nodejs/node/pull/10561 Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
46 lines
1.1 KiB
JavaScript
46 lines
1.1 KiB
JavaScript
'use strict';
|
|
|
|
/*eslint complexity: 0*/
|
|
|
|
module.exports = function equal(a, b) {
|
|
if (a === b) return true;
|
|
|
|
var arrA = Array.isArray(a)
|
|
, arrB = Array.isArray(b)
|
|
, i;
|
|
|
|
if (arrA && arrB) {
|
|
if (a.length != b.length) return false;
|
|
for (i = 0; i < a.length; i++)
|
|
if (!equal(a[i], b[i])) return false;
|
|
return true;
|
|
}
|
|
|
|
if (arrA != arrB) return false;
|
|
|
|
if (a && b && typeof a === 'object' && typeof b === 'object') {
|
|
var keys = Object.keys(a);
|
|
if (keys.length !== Object.keys(b).length) return false;
|
|
|
|
var dateA = a instanceof Date
|
|
, dateB = b instanceof Date;
|
|
if (dateA && dateB) return a.getTime() == b.getTime();
|
|
if (dateA != dateB) return false;
|
|
|
|
var regexpA = a instanceof RegExp
|
|
, regexpB = b instanceof RegExp;
|
|
if (regexpA && regexpB) return a.toString() == b.toString();
|
|
if (regexpA != regexpB) return false;
|
|
|
|
for (i = 0; i < keys.length; i++)
|
|
if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
|
|
|
|
for (i = 0; i < keys.length; i++)
|
|
if(!equal(a[keys[i]], b[keys[i]])) return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
};
|