use directories for structure

This commit is contained in:
s2
2020-05-26 10:37:57 +02:00
parent 66580d4847
commit ae4aaf2668
1287 changed files with 92093 additions and 13113 deletions

View File

@@ -1,8 +1,8 @@
# fast-deep-equal
The fastest 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 version](https://badge.fury.io/js/fast-deep-equal.svg)](http://badge.fury.io/js/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)
@@ -16,9 +16,14 @@ npm install fast-deep-equal
## Features
- ES5 compatible
- works in node.js (0.10+) and browsers (IE9+)
- 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
@@ -27,31 +32,64 @@ 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 v9.11.1:
Node.js v12.6.0:
```
fast-deep-equal x 226,960 ops/sec ±1.55% (86 runs sampled)
nano-equal x 218,210 ops/sec ±0.79% (89 runs sampled)
shallow-equal-fuzzy x 206,762 ops/sec ±0.84% (88 runs sampled)
underscore.isEqual x 128,668 ops/sec ±0.75% (91 runs sampled)
lodash.isEqual x 44,895 ops/sec ±0.67% (85 runs sampled)
deep-equal x 51,616 ops/sec ±0.96% (90 runs sampled)
deep-eql x 28,218 ops/sec ±0.42% (85 runs sampled)
assert.deepStrictEqual x 1,777 ops/sec ±1.05% (86 runs sampled)
ramda.equals x 13,466 ops/sec ±0.82% (86 runs sampled)
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 install
node benchmark
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

2
node_modules/fast-deep-equal/es6/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
const equal: (a: any, b: any) => boolean;
export = equal;

72
node_modules/fast-deep-equal/es6/index.js generated vendored Normal file
View File

@@ -0,0 +1,72 @@
'use strict';
// do not edit .js files directly - edit src/index.jst
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;
}
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];
if (!equal(a[key], b[key])) return false;
}
return true;
}
// true if both NaN, false otherwise
return a!==a && b!==b;
};

2
node_modules/fast-deep-equal/es6/react.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
const equal: (a: any, b: any) => boolean;
export = equal;

79
node_modules/fast-deep-equal/es6/react.js generated vendored Normal file
View File

@@ -0,0 +1,79 @@
'use strict';
// do not edit .js files directly - edit src/index.jst
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;
}
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];
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;
};

View File

@@ -1,20 +1,17 @@
'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;
if (a && b && typeof a == 'object' && typeof b == 'object') {
var arrA = isArray(a)
, arrB = isArray(b)
, i
, length
, key;
if (a.constructor !== b.constructor) return false;
if (arrA && arrB) {
var length, i, keys;
if (Array.isArray(a)) {
length = a.length;
if (length != b.length) return false;
for (i = length; i-- !== 0;)
@@ -22,34 +19,28 @@ module.exports = function equal(a, b) {
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();
var keys = keyList(a);
keys = Object.keys(a);
length = keys.length;
if (length !== keyList(b).length)
return false;
if (length !== Object.keys(b).length) return false;
for (i = length; i-- !== 0;)
if (!hasProp.call(b, keys[i])) return false;
if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
for (i = length; i-- !== 0;) {
key = keys[i];
var key = keys[i];
if (!equal(a[key], b[key])) return false;
}
return true;
}
// true if both NaN, false otherwise
return a!==a && b!==b;
};

View File

@@ -1,27 +1,27 @@
{
"_from": "fast-deep-equal@^2.0.1",
"_id": "fast-deep-equal@2.0.1",
"_from": "fast-deep-equal@^3.1.1",
"_id": "fast-deep-equal@3.1.1",
"_inBundle": false,
"_integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=",
"_integrity": "sha512-8UEa58QDLauDNfpbrX55Q9jrGHThw2ZMdOky5Gl1CDtVeJDPVrG4Jxx1N8jw2gkWaff5UUuX1KJd+9zGe2B+ZA==",
"_location": "/fast-deep-equal",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "fast-deep-equal@^2.0.1",
"raw": "fast-deep-equal@^3.1.1",
"name": "fast-deep-equal",
"escapedName": "fast-deep-equal",
"rawSpec": "^2.0.1",
"rawSpec": "^3.1.1",
"saveSpec": null,
"fetchSpec": "^2.0.1"
"fetchSpec": "^3.1.1"
},
"_requiredBy": [
"/ajv"
],
"_resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz",
"_shasum": "7b05218ddf9667bf7f370bf7fdb2cb15fdd0aa49",
"_spec": "fast-deep-equal@^2.0.1",
"_where": "F:\\projects\\vanillajs-seed\\node_modules\\ajv",
"_resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.1.tgz",
"_shasum": "545145077c501491e33b15ec408c294376e94ae4",
"_spec": "fast-deep-equal@^3.1.1",
"_where": "D:\\Projects\\siag\\vanillajs-seed\\node_modules\\ajv",
"author": {
"name": "Evgeny Poberezkin"
},
@@ -32,24 +32,23 @@
"deprecated": false,
"description": "Fast deep equal",
"devDependencies": {
"benchmark": "^2.1.4",
"coveralls": "^2.13.1",
"deep-eql": "latest",
"deep-equal": "latest",
"dot": "^1.1.2",
"eslint": "^4.0.0",
"lodash": "latest",
"mocha": "^3.4.2",
"nano-equal": "latest",
"nyc": "^11.0.2",
"pre-commit": "^1.2.2",
"ramda": "latest",
"shallow-equal-fuzzy": "latest",
"typescript": "^2.6.1",
"underscore": "latest"
"react": "^16.12.0",
"react-test-renderer": "^16.12.0",
"sinon": "^7.5.0",
"typescript": "^2.6.1"
},
"files": [
"index.js",
"index.d.ts"
"index.d.ts",
"react.js",
"react.d.ts",
"es6/"
],
"homepage": "https://github.com/epoberezkin/fast-deep-equal#readme",
"keywords": [
@@ -75,12 +74,15 @@
"url": "git+https://github.com/epoberezkin/fast-deep-equal.git"
},
"scripts": {
"eslint": "eslint *.js benchmark spec",
"test": "npm run eslint && npm run test-ts && npm run test-cov",
"benchmark": "npm i && npm run build && cd ./benchmark && npm i && node ./",
"build": "node build",
"eslint": "eslint *.js benchmark/*.js spec/*.js",
"prepublish": "npm run build",
"test": "npm run build && npm run eslint && npm run test-ts && npm run test-cov",
"test-cov": "nyc npm run test-spec",
"test-spec": "mocha spec/*.spec.js -R spec",
"test-ts": "tsc --target ES5 --noImplicitAny index.d.ts"
},
"types": "index.d.ts",
"version": "2.0.1"
"version": "3.1.1"
}

2
node_modules/fast-deep-equal/react.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
const equal: (a: any, b: any) => boolean;
export = equal;

53
node_modules/fast-deep-equal/react.js generated vendored Normal file
View File

@@ -0,0 +1,53 @@
'use strict';
// do not edit .js files directly - edit src/index.jst
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;
}
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];
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;
};