Sha256: 0f142b56c78d32f656089e8429364407675fc7cb4e7358f1cb68bd742b16eb03

Contents?: true

Size: 1.12 KB

Versions: 53

Compression:

Stored size: 1.12 KB

Contents

'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;
};

Version data entries

53 entries across 53 versions & 7 rubygems

Version Path
ilog-0.4.1 node_modules/ajv/lib/compile/equal.js
ilog-0.4.0 node_modules/ajv/lib/compile/equal.js
ilog-0.3.3 node_modules/ajv/lib/compile/equal.js
govuk_publishing_components-18.0.0 node_modules/ajv/lib/compile/equal.js
govuk_publishing_components-17.21.0 node_modules/ajv/lib/compile/equal.js
govuk_publishing_components-17.20.0 node_modules/ajv/lib/compile/equal.js
govuk_publishing_components-17.19.1 node_modules/ajv/lib/compile/equal.js
govuk_publishing_components-17.19.0 node_modules/ajv/lib/compile/equal.js
govuk_publishing_components-17.18.0 node_modules/ajv/lib/compile/equal.js
govuk_publishing_components-17.17.0 node_modules/ajv/lib/compile/equal.js
govuk_publishing_components-17.16.0 node_modules/ajv/lib/compile/equal.js
govuk_publishing_components-17.15.0 node_modules/ajv/lib/compile/equal.js
govuk_publishing_components-17.14.0 node_modules/ajv/lib/compile/equal.js
govuk_publishing_components-17.13.0 node_modules/ajv/lib/compile/equal.js
govuk_publishing_components-17.12.2 node_modules/ajv/lib/compile/equal.js
govuk_publishing_components-17.12.1 node_modules/ajv/lib/compile/equal.js
govuk_publishing_components-17.12.0 node_modules/ajv/lib/compile/equal.js
govuk_publishing_components-17.11.0 node_modules/ajv/lib/compile/equal.js
govuk_publishing_components-17.10.0 node_modules/ajv/lib/compile/equal.js
govuk_publishing_components-17.9.0 node_modules/ajv/lib/compile/equal.js