pax_global_header00006660000000000000000000000064136673637220014531gustar00rootroot0000000000000052 comment=d807ffc5013e710deb1c63d463a03f729bcd144d fast-deep-equal-3.1.3/000077500000000000000000000000001366736372200145125ustar00rootroot00000000000000fast-deep-equal-3.1.3/.eslintrc.yml000066400000000000000000000014011366736372200171320ustar00rootroot00000000000000env: node: true extends: 'eslint:recommended' rules: indent: [ 2, 2, { SwitchCase: 1 } ] no-trailing-spaces: 2 quotes: [ 2, single, avoid-escape ] linebreak-style: [ 2, unix ] semi: [ 2, always ] valid-jsdoc: [ 2, { requireReturn: false } ] no-invalid-this: 2 no-unused-vars: [ 2, { args: none } ] no-console: [ 2, { allow: [ warn, error ] } ] block-scoped-var: 2 curly: [ 2, multi-or-nest, consistent ] dot-location: [ 2, property ] dot-notation: 2 no-else-return: 2 no-eq-null: 2 no-fallthrough: 2 no-return-assign: 2 strict: [ 2, global ] no-use-before-define: [ 2, nofunc ] callback-return: 2 no-path-concat: 2 no-empty: 0 globals: document: false Element: false beforeEach: false afterEach: false xit: false fast-deep-equal-3.1.3/.github/000077500000000000000000000000001366736372200160525ustar00rootroot00000000000000fast-deep-equal-3.1.3/.github/FUNDING.yml000066400000000000000000000000641366736372200176670ustar00rootroot00000000000000github: epoberezkin tidelift: "npm/fast-deep-equal" fast-deep-equal-3.1.3/.gitignore000066400000000000000000000017241366736372200165060ustar00rootroot00000000000000# Logs logs *.log npm-debug.log* yarn-debug.log* yarn-error.log* # Runtime data pids *.pid *.seed *.pid.lock # Directory for instrumented libs generated by jscoverage/JSCover lib-cov # Coverage directory used by tools like istanbul coverage # nyc test coverage .nyc_output # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) .grunt # Bower dependency directory (https://bower.io/) bower_components # node-waf configuration .lock-wscript # Compiled binary addons (http://nodejs.org/api/addons.html) build/Release # Dependency directories node_modules/ jspm_packages/ # Typescript v1 declaration files typings/ # Optional npm cache directory .npm # Optional eslint cache .eslintcache # Optional REPL history .node_repl_history # Output of 'npm pack' *.tgz # Yarn Integrity file .yarn-integrity # Lock files package-lock.json yarn.lock # dotenv environment variables file .env .DS_Store # generated files index.js react.js .idea fast-deep-equal-3.1.3/.travis.yml000066400000000000000000000001601366736372200166200ustar00rootroot00000000000000language: node_js node_js: - "10" - "12" - "13" - "14" after_script: - coveralls < coverage/lcov.info fast-deep-equal-3.1.3/LICENSE000066400000000000000000000020621366736372200155170ustar00rootroot00000000000000MIT License Copyright (c) 2017 Evgeny Poberezkin Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. fast-deep-equal-3.1.3/README.md000066400000000000000000000063731366736372200160020ustar00rootroot00000000000000# fast-deep-equal The fastest deep equal with ES6 Map, Set and Typed arrays support. [![Build Status](https://travis-ci.org/epoberezkin/fast-deep-equal.svg?branch=master)](https://travis-ci.org/epoberezkin/fast-deep-equal) [![npm](https://img.shields.io/npm/v/fast-deep-equal.svg)](https://www.npmjs.com/package/fast-deep-equal) [![Coverage Status](https://coveralls.io/repos/github/epoberezkin/fast-deep-equal/badge.svg?branch=master)](https://coveralls.io/github/epoberezkin/fast-deep-equal?branch=master) ## Install ```bash npm install fast-deep-equal ``` ## Features - ES5 compatible - works in node.js (8+) and browsers (IE9+) - checks equality of Date and RegExp objects by value. ES6 equal (`require('fast-deep-equal/es6')`) also supports: - Maps - Sets - Typed arrays ## Usage ```javascript var equal = require('fast-deep-equal'); console.log(equal({foo: 'bar'}, {foo: 'bar'})); // true ``` To support ES6 Maps, Sets and Typed arrays equality use: ```javascript var equal = require('fast-deep-equal/es6'); console.log(equal(Int16Array([1, 2]), Int16Array([1, 2]))); // true ``` To use with React (avoiding the traversal of React elements' _owner property that contains circular references and is not needed when comparing the elements - borrowed from [react-fast-compare](https://github.com/FormidableLabs/react-fast-compare)): ```javascript var equal = require('fast-deep-equal/react'); var equal = require('fast-deep-equal/es6/react'); ``` ## Performance benchmark Node.js v12.6.0: ``` fast-deep-equal x 261,950 ops/sec ±0.52% (89 runs sampled) fast-deep-equal/es6 x 212,991 ops/sec ±0.34% (92 runs sampled) fast-equals x 230,957 ops/sec ±0.83% (85 runs sampled) nano-equal x 187,995 ops/sec ±0.53% (88 runs sampled) shallow-equal-fuzzy x 138,302 ops/sec ±0.49% (90 runs sampled) underscore.isEqual x 74,423 ops/sec ±0.38% (89 runs sampled) lodash.isEqual x 36,637 ops/sec ±0.72% (90 runs sampled) deep-equal x 2,310 ops/sec ±0.37% (90 runs sampled) deep-eql x 35,312 ops/sec ±0.67% (91 runs sampled) ramda.equals x 12,054 ops/sec ±0.40% (91 runs sampled) util.isDeepStrictEqual x 46,440 ops/sec ±0.43% (90 runs sampled) assert.deepStrictEqual x 456 ops/sec ±0.71% (88 runs sampled) The fastest is fast-deep-equal ``` To run benchmark (requires node.js 6+): ```bash npm run benchmark ``` __Please note__: this benchmark runs against the available test cases. To choose the most performant library for your application, it is recommended to benchmark against your data and to NOT expect this benchmark to reflect the performance difference in your application. ## Enterprise support fast-deep-equal package is a part of [Tidelift enterprise subscription](https://tidelift.com/subscription/pkg/npm-fast-deep-equal?utm_source=npm-fast-deep-equal&utm_medium=referral&utm_campaign=enterprise&utm_term=repo) - it provides a centralised commercial support to open-source software users, in addition to the support provided by software maintainers. ## Security contact To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure. Please do NOT report security vulnerability via GitHub issues. ## License [MIT](https://github.com/epoberezkin/fast-deep-equal/blob/master/LICENSE) fast-deep-equal-3.1.3/benchmark/000077500000000000000000000000001366736372200164445ustar00rootroot00000000000000fast-deep-equal-3.1.3/benchmark/.eslintrc.yml000066400000000000000000000001171366736372200210670ustar00rootroot00000000000000parserOptions: ecmaVersion: 2016 rules: no-invalid-this: 0 no-console: 0 fast-deep-equal-3.1.3/benchmark/index.js000066400000000000000000000033711366736372200201150ustar00rootroot00000000000000'use strict'; const assertDeepStrictEqual = require('assert').deepStrictEqual; const tests = require('../spec/tests'); const Benchmark = require('benchmark'); const suite = new Benchmark.Suite; const equalPackages = { 'fast-deep-equal': require('..'), 'fast-deep-equal/es6': require('../es6'), 'fast-equals': require('fast-equals').deepEqual, 'nano-equal': true, 'shallow-equal-fuzzy': true, 'underscore.isEqual': require('underscore').isEqual, 'lodash.isEqual': require('lodash').isEqual, 'deep-equal': true, 'deep-eql': true, 'ramda.equals': require('ramda').equals, 'util.isDeepStrictEqual': require('util').isDeepStrictEqual, 'assert.deepStrictEqual': (a, b) => { try { assertDeepStrictEqual(a, b); return true; } catch(e) { return false; } } }; for (const equalName in equalPackages) { let equalFunc = equalPackages[equalName]; if (equalFunc === true) equalFunc = require(equalName); for (const testSuite of tests) { for (const test of testSuite.tests) { try { if (equalFunc(test.value1, test.value2) !== test.equal) console.error('different result', equalName, testSuite.description, test.description); } catch(e) { console.error(equalName, testSuite.description, test.description, e); } } } suite.add(equalName, function() { for (const testSuite of tests) { for (const test of testSuite.tests) { if (test.description != 'pseudo array and equivalent array are not equal') equalFunc(test.value1, test.value2); } } }); } console.log(); suite .on('cycle', (event) => console.log(String(event.target))) .on('complete', function () { console.log('The fastest is ' + this.filter('fastest').map('name')); }) .run({async: true}); fast-deep-equal-3.1.3/benchmark/package.json000066400000000000000000000004521366736372200207330ustar00rootroot00000000000000{ "private": true, "devDependencies": { "benchmark": "^2.1.4", "deep-eql": "latest", "deep-equal": "latest", "fast-equals": "latest", "lodash": "latest", "nano-equal": "latest", "ramda": "latest", "shallow-equal-fuzzy": "latest", "underscore": "latest" } }fast-deep-equal-3.1.3/build.js000066400000000000000000000007011366736372200161450ustar00rootroot00000000000000'use strict'; var fs = require('fs'); var doT = require('dot'); doT.templateSettings.strip = false; var jst = doT.compile(fs.readFileSync('./src/index.jst', 'utf8')); fs.writeFileSync('./index.js', jst({es6: false})); fs.writeFileSync('./react.js', jst({es6: false, react: true})); try { fs.mkdirSync('./es6'); } catch(e) {} fs.writeFileSync('./es6/index.js', jst({es6: true})); fs.writeFileSync('./es6/react.js', jst({es6: true, react: true})); fast-deep-equal-3.1.3/es6/000077500000000000000000000000001366736372200152075ustar00rootroot00000000000000fast-deep-equal-3.1.3/es6/index.d.ts000066400000000000000000000001021366736372200171010ustar00rootroot00000000000000declare const equal: (a: any, b: any) => boolean; export = equal; fast-deep-equal-3.1.3/es6/react.d.ts000066400000000000000000000001021366736372200170700ustar00rootroot00000000000000declare const equal: (a: any, b: any) => boolean; export = equal; fast-deep-equal-3.1.3/index.d.ts000066400000000000000000000001471366736372200164150ustar00rootroot00000000000000declare module 'fast-deep-equal' { const equal: (a: any, b: any) => boolean; export = equal; } fast-deep-equal-3.1.3/package.json000066400000000000000000000027301366736372200170020ustar00rootroot00000000000000{ "name": "fast-deep-equal", "version": "3.1.3", "description": "Fast deep equal", "main": "index.js", "scripts": { "eslint": "eslint *.js benchmark/*.js spec/*.js", "build": "node build", "benchmark": "npm i && npm run build && cd ./benchmark && npm i && node ./", "test-spec": "mocha spec/*.spec.js -R spec", "test-cov": "nyc npm run test-spec", "test-ts": "tsc --target ES5 --noImplicitAny index.d.ts", "test": "npm run build && npm run eslint && npm run test-ts && npm run test-cov", "prepublish": "npm run build" }, "repository": { "type": "git", "url": "git+https://github.com/epoberezkin/fast-deep-equal.git" }, "keywords": [ "fast", "equal", "deep-equal" ], "author": "Evgeny Poberezkin", "license": "MIT", "bugs": { "url": "https://github.com/epoberezkin/fast-deep-equal/issues" }, "homepage": "https://github.com/epoberezkin/fast-deep-equal#readme", "devDependencies": { "coveralls": "^3.1.0", "dot": "^1.1.2", "eslint": "^7.2.0", "mocha": "^7.2.0", "nyc": "^15.1.0", "pre-commit": "^1.2.2", "react": "^16.12.0", "react-test-renderer": "^16.12.0", "sinon": "^9.0.2", "typescript": "^3.9.5" }, "nyc": { "exclude": [ "**/spec/**", "node_modules" ], "reporter": [ "lcov", "text-summary" ] }, "files": [ "index.js", "index.d.ts", "react.js", "react.d.ts", "es6/" ], "types": "index.d.ts" } fast-deep-equal-3.1.3/react.d.ts000066400000000000000000000001021366736372200163730ustar00rootroot00000000000000declare const equal: (a: any, b: any) => boolean; export = equal; fast-deep-equal-3.1.3/spec/000077500000000000000000000000001366736372200154445ustar00rootroot00000000000000fast-deep-equal-3.1.3/spec/.eslintrc.yml000066400000000000000000000001671366736372200200740ustar00rootroot00000000000000env: es6: true rules: no-console: 0 globals: describe: false it: false BigInt: false BigUint64Array: false fast-deep-equal-3.1.3/spec/es6tests.js000066400000000000000000000213371366736372200175700ustar00rootroot00000000000000'use strict'; class MyMap extends Map {} class MySet extends Set {} var emptyObj = {}; var skipBigInt = typeof BigInt == 'undefined'; var skipBigIntArray = typeof BigUint64Array == 'undefined'; module.exports = [ { description: 'bigint', tests: [ { description: 'equal bigints', value1: skipBigInt || BigInt(1), value2: skipBigInt || BigInt(1), equal: true, skip: skipBigInt }, { description: 'not equal bigints', value1: skipBigInt || BigInt(1), value2: skipBigInt || BigInt(2), equal: false, skip: skipBigInt } ] }, { description: 'Maps', tests: [ { description: 'empty maps are equal', value1: new Map, value2: new Map, equal: true }, { description: 'empty maps of different class are not equal', value1: new Map, value2: new MyMap, equal: false }, { description: 'equal maps (same key "order")', value1: map({a: 1, b: '2'}), value2: map({a: 1, b: '2'}), equal: true }, { description: 'not equal maps (same key "order" - instances of different classes)', value1: map({a: 1, b: '2'}), value2: myMap({a: 1, b: '2'}), equal: false }, { description: 'equal maps (different key "order")', value1: map({a: 1, b: '2'}), value2: map({b: '2', a: 1}), equal: true }, { description: 'equal maps (different key "order" - instances of the same subclass)', value1: myMap({a: 1, b: '2'}), value2: myMap({b: '2', a: 1}), equal: true }, { description: 'not equal maps (extra key)', value1: map({a: 1, b: '2'}), value2: map({a: 1, b: '2', c: []}), equal: false }, { description: 'not equal maps (different key value)', value1: map({a: 1, b: '2', c: 3}), value2: map({a: 1, b: '2', c: 4}), equal: false }, { description: 'not equal maps (different keys)', value1: map({a: 1, b: '2', c: 3}), value2: map({a: 1, b: '2', d: 3}), equal: false }, { description: 'equal maps (same sub-keys)', value1: map({ a: [ map({ b: 'c' }) ] }), value2: map({ a: [ map({ b: 'c' }) ] }), equal: true }, { description: 'not equal maps (different sub-key value)', value1: map({ a: [ map({ b: 'c' }) ] }), value2: map({ a: [ map({ b: 'd' }) ] }), equal: false }, { description: 'not equal maps (different sub-key)', value1: map({ a: [ map({ b: 'c' }) ] }), value2: map({ a: [ map({ c: 'c' }) ] }), equal: false }, { description: 'empty map and empty object are not equal', value1: {}, value2: new Map, equal: false }, { description: 'map with extra undefined key is not equal #1', value1: map({}), value2: map({foo: undefined}), equal: false }, { description: 'map with extra undefined key is not equal #2', value1: map({foo: undefined}), value2: map({}), equal: false }, { description: 'maps with extra undefined keys are not equal #3', value1: map({foo: undefined}), value2: map({bar: undefined}), equal: false }, { description: 'null and empty map are not equal', value1: null, value2: new Map, equal: false }, { description: 'undefined and empty map are not equal', value1: undefined, value2: new Map, equal: false }, { description: 'map and a pseudo map are not equal', value1: map({}), value2: { constructor: Map, size: 0, has: () => true, get: () => 1, }, equal: false }, ] }, { description: 'Sets', tests: [ { description: 'empty sets are equal', value1: new Set, value2: new Set, equal: true }, { description: 'empty sets of different class are not equal', value1: new Set, value2: new MySet, equal: false }, { description: 'equal sets (same value "order")', value1: set(['a', 'b']), value2: set(['a', 'b']), equal: true }, { description: 'not equal sets (same value "order" - instances of different classes)', value1: set(['a', 'b']), value2: mySet(['a', 'b']), equal: false }, { description: 'equal sets (different value "order")', value1: set(['a', 'b']), value2: set(['b', 'a']), equal: true }, { description: 'equal sets (different value "order" - instances of the same subclass)', value1: mySet(['a', 'b']), value2: mySet(['b', 'a']), equal: true }, { description: 'not equal sets (extra value)', value1: set(['a', 'b']), value2: set(['a', 'b', 'c']), equal: false }, { description: 'not equal sets (different values)', value1: set(['a', 'b', 'c']), value2: set(['a', 'b', 'd']), equal: false }, { description: 'not equal sets (different instances of objects)', value1: set([ 'a', {} ]), value2: set([ 'a', {} ]), equal: false }, { description: 'equal sets (same instances of objects)', value1: set([ 'a', emptyObj ]), value2: set([ 'a', emptyObj ]), equal: true }, { description: 'empty set and empty object are not equal', value1: {}, value2: new Set, equal: false }, { description: 'empty set and empty array are not equal', value1: [], value2: new Set, equal: false }, { description: 'set with extra undefined value is not equal #1', value1: set([]), value2: set([undefined]), equal: false }, { description: 'set with extra undefined value is not equal #2', value1: set([undefined]), value2: set([]), equal: false }, { description: 'set and pseudo set are not equal', value1: new Set, value2: { constructor: Set, size: 0, has: () => true, }, equal: false }, ] }, { description: 'Typed arrays', tests: [ { description: 'two empty arrays of the same class are equal', value1: new Int32Array([]), value2: new Int32Array([]), equal: true }, { description: 'two empty arrays of the different class are not equal', value1: new Int32Array([]), value2: new Int16Array([]), equal: false }, { description: 'equal arrays', value1: new Int32Array([1, 2, 3]), value2: new Int32Array([1, 2, 3]), equal: true }, { description: 'equal BigUint64Array arrays', value1: skipBigIntArray || new BigUint64Array(['1', '2', '3']), value2: skipBigIntArray || new BigUint64Array(['1', '2', '3']), equal: true, skip: skipBigIntArray }, { description: 'not equal BigUint64Array arrays', value1: skipBigIntArray || new BigUint64Array(['1', '2', '3']), value2: skipBigIntArray || new BigUint64Array(['1', '2', '4']), equal: false, skip: skipBigIntArray }, { description: 'not equal arrays (same items, different class)', value1: new Int32Array([1, 2, 3]), value2: new Int16Array([1, 2, 3]), equal: false }, { description: 'not equal arrays (different item)', value1: new Int32Array([1, 2, 3]), value2: new Int32Array([1, 2, 4]), equal: false }, { description: 'not equal arrays (different length)', value1: new Int32Array([1, 2, 3]), value2: new Int32Array([1, 2]), equal: false }, { description: 'pseudo array and equivalent typed array are not equal', value1: {'0': 1, '1': 2, length: 2, constructor: Int32Array}, value2: new Int32Array([1, 2]), equal: false } ] } ]; function map(obj, Class) { var a = new (Class || Map); for (var key in obj) a.set(key, obj[key]); return a; } function myMap(obj) { return map(obj, MyMap); } function set(arr, Class) { var a = new (Class || Set); for (var value of arr) a.add(value); return a; } function mySet(arr) { return set(arr, MySet); } fast-deep-equal-3.1.3/spec/index.spec.js000066400000000000000000000023401366736372200200410ustar00rootroot00000000000000'use strict'; var equal = require('..'); var equalReact = require('../react'); var es6equal = require('../es6'); var es6equalReact = require('../es6/react'); var assert = require('assert'); testCases(equal, 'equal - standard tests', require('./tests')); testCases(es6equal, 'es6 equal - standard tests', require('./tests')); testCases(es6equal, 'es6 equal - es6 tests', require('./es6tests')); testCases(equalReact, 'equal react - standard tests', require('./tests')); testCases(es6equalReact, 'es6 equal react - standard tests', require('./tests')); testCases(es6equalReact, 'es6 equal react - es6 tests', require('./es6tests')); function testCases(equalFunc, suiteName, suiteTests) { describe(suiteName, function() { suiteTests.forEach(function (suite) { describe(suite.description, function() { suite.tests.forEach(function (test) { (test.skip ? it.skip : it)(test.description, function() { assert.strictEqual(equalFunc(test.value1, test.value2), test.equal); }); (test.skip ? it.skip : it)(test.description + ' (reverse arguments)', function() { assert.strictEqual(equalFunc(test.value2, test.value1), test.equal); }); }); }); }); }); }fast-deep-equal-3.1.3/spec/react.spec.js000066400000000000000000000042771366736372200200430ustar00rootroot00000000000000'use strict'; const assert = require('assert'); const sinon = require('sinon'); const React = require('react'); const ReactTestRenderer = require('react-test-renderer'); const equal1 = require('../es6/react'); const equal2 = require('../react'); const run = equal => { class ChildWithShouldComponentUpdate extends React.Component { shouldComponentUpdate(nextProps) { // this.props.children is a h1 with a circular reference to its owner, Container return !equal(this.props, nextProps); } render() { return null; } } class Container extends React.Component { render() { return React.createElement(ChildWithShouldComponentUpdate, { children: [ React.createElement('h1', this.props.title || ''), React.createElement('h2', this.props.subtitle || '') ] }); } } describe('advanced', () => { let sandbox; let warnStub; let childRenderSpy; beforeEach(() => { sandbox = sinon.createSandbox(); warnStub = sandbox.stub(console, 'warn'); childRenderSpy = sandbox.spy(ChildWithShouldComponentUpdate.prototype, 'render'); }); afterEach(() => { sandbox.restore(); }); describe('React', () => { describe('element (with circular references)', () => { it('compares without warning or errors', () => { const testRenderer = ReactTestRenderer.create(React.createElement(Container)); testRenderer.update(React.createElement(Container)); assert.strictEqual(warnStub.callCount, 0); }); it('elements of same type and props are equal', () => { const testRenderer = ReactTestRenderer.create(React.createElement(Container)); testRenderer.update(React.createElement(Container)); assert.strictEqual(childRenderSpy.callCount, 1); }); it('elements of same type with different props are not equal', () => { const testRenderer = ReactTestRenderer.create(React.createElement(Container)); testRenderer.update(React.createElement(Container, { title: 'New' })); assert.strictEqual(childRenderSpy.callCount, 2); }); }); }); }); }; run(equal1); run(equal2); fast-deep-equal-3.1.3/spec/tests.js000066400000000000000000000224451366736372200171530ustar00rootroot00000000000000'use strict'; module.exports = [ { description: 'scalars', tests: [ { description: 'equal numbers', value1: 1, value2: 1, equal: true }, { description: 'not equal numbers', value1: 1, value2: 2, equal: false }, { description: 'number and array are not equal', value1: 1, value2: [], equal: false }, { description: '0 and null are not equal', value1: 0, value2: null, equal: false }, { description: 'equal strings', value1: 'a', value2: 'a', equal: true }, { description: 'not equal strings', value1: 'a', value2: 'b', equal: false }, { description: 'empty string and null are not equal', value1: '', value2: null, equal: false }, { description: 'null is equal to null', value1: null, value2: null, equal: true }, { description: 'equal booleans (true)', value1: true, value2: true, equal: true }, { description: 'equal booleans (false)', value1: false, value2: false, equal: true }, { description: 'not equal booleans', value1: true, value2: false, equal: false }, { description: '1 and true are not equal', value1: 1, value2: true, equal: false }, { description: '0 and false are not equal', value1: 0, value2: false, equal: false }, { description: 'NaN and NaN are equal', value1: NaN, value2: NaN, equal: true }, { description: '0 and -0 are equal', value1: 0, value2: -0, equal: true }, { description: 'Infinity and Infinity are equal', value1: Infinity, value2: Infinity, equal: true }, { description: 'Infinity and -Infinity are not equal', value1: Infinity, value2: -Infinity, equal: false } ] }, { description: 'objects', tests: [ { description: 'empty objects are equal', value1: {}, value2: {}, equal: true }, { description: 'equal objects (same properties "order")', value1: {a: 1, b: '2'}, value2: {a: 1, b: '2'}, equal: true }, { description: 'equal objects (different properties "order")', value1: {a: 1, b: '2'}, value2: {b: '2', a: 1}, equal: true }, { description: 'not equal objects (extra property)', value1: {a: 1, b: '2'}, value2: {a: 1, b: '2', c: []}, equal: false }, { description: 'not equal objects (different property values)', value1: {a: 1, b: '2', c: 3}, value2: {a: 1, b: '2', c: 4}, equal: false }, { description: 'not equal objects (different properties)', value1: {a: 1, b: '2', c: 3}, value2: {a: 1, b: '2', d: 3}, equal: false }, { description: 'equal objects (same sub-properties)', value1: { a: [ { b: 'c' } ] }, value2: { a: [ { b: 'c' } ] }, equal: true }, { description: 'not equal objects (different sub-property value)', value1: { a: [ { b: 'c' } ] }, value2: { a: [ { b: 'd' } ] }, equal: false }, { description: 'not equal objects (different sub-property)', value1: { a: [ { b: 'c' } ] }, value2: { a: [ { c: 'c' } ] }, equal: false }, { description: 'empty array and empty object are not equal', value1: {}, value2: [], equal: false }, { description: 'object with extra undefined properties are not equal #1', value1: {}, value2: {foo: undefined}, equal: false }, { description: 'object with extra undefined properties are not equal #2', value1: {foo: undefined}, value2: {}, equal: false }, { description: 'object with extra undefined properties are not equal #3', value1: {foo: undefined}, value2: {bar: undefined}, equal: false }, { description: 'nulls are equal', value1: null, value2: null, equal: true }, { description: 'null and undefined are not equal', value1: null, value2: undefined, equal: false }, { description: 'null and empty object are not equal', value1: null, value2: {}, equal: false }, { description: 'undefined and empty object are not equal', value1: undefined, value2: {}, equal: false }, { description: 'objects with different `toString` functions returning same values are equal', value1: {toString: ()=>'Hello world!'}, value2: {toString: ()=>'Hello world!'}, equal: true }, { description: 'objects with `toString` functions returning different values are not equal', value1: {toString: ()=>'Hello world!'}, value2: {toString: ()=>'Hi!'}, equal: false } ] }, { description: 'arrays', tests: [ { description: 'two empty arrays are equal', value1: [], value2: [], equal: true }, { description: 'equal arrays', value1: [1, 2, 3], value2: [1, 2, 3], equal: true }, { description: 'not equal arrays (different item)', value1: [1, 2, 3], value2: [1, 2, 4], equal: false }, { description: 'not equal arrays (different length)', value1: [1, 2, 3], value2: [1, 2], equal: false }, { description: 'equal arrays of objects', value1: [{a: 'a'}, {b: 'b'}], value2: [{a: 'a'}, {b: 'b'}], equal: true }, { description: 'not equal arrays of objects', value1: [{a: 'a'}, {b: 'b'}], value2: [{a: 'a'}, {b: 'c'}], equal: false }, { description: 'pseudo array and equivalent array are not equal', value1: {'0': 0, '1': 1, length: 2}, value2: [0, 1], equal: false } ] }, { description: 'Date objects', tests: [ { description: 'equal date objects', value1: new Date('2017-06-16T21:36:48.362Z'), value2: new Date('2017-06-16T21:36:48.362Z'), equal: true }, { description: 'not equal date objects', value1: new Date('2017-06-16T21:36:48.362Z'), value2: new Date('2017-01-01T00:00:00.000Z'), equal: false }, { description: 'date and string are not equal', value1: new Date('2017-06-16T21:36:48.362Z'), value2: '2017-06-16T21:36:48.362Z', equal: false }, { description: 'date and object are not equal', value1: new Date('2017-06-16T21:36:48.362Z'), value2: {}, equal: false } ] }, { description: 'RegExp objects', tests: [ { description: 'equal RegExp objects', value1: /foo/, value2: /foo/, equal: true }, { description: 'not equal RegExp objects (different pattern)', value1: /foo/, value2: /bar/, equal: false }, { description: 'not equal RegExp objects (different flags)', value1: /foo/, value2: /foo/i, equal: false }, { description: 'RegExp and string are not equal', value1: /foo/, value2: 'foo', equal: false }, { description: 'RegExp and object are not equal', value1: /foo/, value2: {}, equal: false } ] }, { description: 'functions', tests: [ { description: 'same function is equal', value1: func1, value2: func1, equal: true }, { description: 'different functions are not equal', value1: func1, value2: func2, equal: false } ] }, { description: 'sample objects', tests: [ { description: 'big object', value1: { prop1: 'value1', prop2: 'value2', prop3: 'value3', prop4: { subProp1: 'sub value1', subProp2: { subSubProp1: 'sub sub value1', subSubProp2: [1, 2, {prop2: 1, prop: 2}, 4, 5] } }, prop5: 1000, prop6: new Date(2016, 2, 10) }, value2: { prop5: 1000, prop3: 'value3', prop1: 'value1', prop2: 'value2', prop6: new Date('2016/03/10'), prop4: { subProp2: { subSubProp1: 'sub sub value1', subSubProp2: [1, 2, {prop2: 1, prop: 2}, 4, 5] }, subProp1: 'sub value1' } }, equal: true } ] } ]; function func1() {} function func2() {} fast-deep-equal-3.1.3/src/000077500000000000000000000000001366736372200153015ustar00rootroot00000000000000fast-deep-equal-3.1.3/src/index.jst000066400000000000000000000043311366736372200171330ustar00rootroot00000000000000'use strict'; // do not edit .js files directly - edit src/index.jst {{? it.es6 }} var envHasBigInt64Array = typeof BigInt64Array !== 'undefined'; {{?}} module.exports = function equal(a, b) { if (a === b) 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; } {{? it.es6 }} if ((a instanceof Map) && (b instanceof Map)) { if (a.size !== b.size) return false; for (i of a.entries()) if (!b.has(i[0])) return false; for (i of a.entries()) if (!equal(i[1], b.get(i[0]))) return false; return true; } if ((a instanceof Set) && (b instanceof Set)) { if (a.size !== b.size) return false; for (i of a.entries()) if (!b.has(i[0])) return false; return true; } if (ArrayBuffer.isView(a) && ArrayBuffer.isView(b)) { length = a.length; if (length != b.length) return false; for (i = length; i-- !== 0;) if (a[i] !== b[i]) return false; return true; } {{?}} 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(); keys = Object.keys(a); length = keys.length; if (length !== Object.keys(b).length) return false; for (i = length; i-- !== 0;) if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false; for (i = length; i-- !== 0;) { var key = keys[i]; {{? it.react }} if (key === '_owner' && a.$$typeof) { // React-specific: avoid traversing React elements' _owner. // _owner contains circular references // and is not needed when comparing the actual elements (and not their owners) continue; } {{?}} if (!equal(a[key], b[key])) return false; } return true; } // true if both NaN, false otherwise return a!==a && b!==b; };