mirror of
https://github.com/10h30/odin-javascript-exercises.git
synced 2026-07-12 11:16:09 +09:00
Clean up the oopsie. Rebuild the blank exercises.
This commit is contained in:
-25
@@ -1,25 +0,0 @@
|
||||
env:
|
||||
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
|
||||
-60
@@ -1,60 +0,0 @@
|
||||
# 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
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
|
||||
.DS_Store
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "4"
|
||||
- "6"
|
||||
- "7"
|
||||
- "8"
|
||||
after_script:
|
||||
- coveralls < coverage/lcov.info
|
||||
+54
-13
@@ -1,8 +1,8 @@
|
||||
# fast-deep-equal
|
||||
The fastest deep equal
|
||||
The fastest deep equal with ES6 Map, Set and Typed arrays support.
|
||||
|
||||
[](https://travis-ci.org/epoberezkin/fast-deep-equal)
|
||||
[](http://badge.fury.io/js/fast-deep-equal)
|
||||
[](https://www.npmjs.com/package/fast-deep-equal)
|
||||
[](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,28 +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 v12.6.0:
|
||||
|
||||
```
|
||||
fast-deep-equal x 82,915 ops/sec ±0.63% (89 runs sampled)
|
||||
nano-equal x 50,506 ops/sec ±2.23% (86 runs sampled)
|
||||
shallow-equal-fuzzy x 14,873 ops/sec ±3.19% (83 runs sampled)
|
||||
underscore.isEqual x 16,055 ops/sec ±2.29% (85 runs sampled)
|
||||
lodash.isEqual x 10,740 ops/sec ±1.04% (89 runs sampled)
|
||||
deep-equal x 12,276 ops/sec ±2.44% (84 runs sampled)
|
||||
deep-eql x 10,565 ops/sec ±0.89% (90 runs sampled)
|
||||
assert.deepStrictEqual x 965 ops/sec ±2.99% (81 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
|
||||
|
||||
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
parserOptions:
|
||||
ecmaVersion: 2016
|
||||
rules:
|
||||
no-invalid-this: 0
|
||||
no-console: 0
|
||||
-56
@@ -1,56 +0,0 @@
|
||||
'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('../index'),
|
||||
'nano-equal': true,
|
||||
'shallow-equal-fuzzy': true,
|
||||
'underscore.isEqual': require('underscore').isEqual,
|
||||
'lodash.isEqual': require('lodash').isEqual,
|
||||
'deep-equal': true,
|
||||
'deep-eql': true,
|
||||
'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});
|
||||
+28
-25
@@ -1,43 +1,46 @@
|
||||
'use strict';
|
||||
|
||||
// do not edit .js files directly - edit src/index.jst
|
||||
|
||||
|
||||
|
||||
module.exports = function equal(a, b) {
|
||||
if (a === b) return true;
|
||||
|
||||
var arrA = Array.isArray(a)
|
||||
, arrB = Array.isArray(b)
|
||||
, i;
|
||||
if (a && b && typeof a == 'object' && typeof b == 'object') {
|
||||
if (a.constructor !== b.constructor) return false;
|
||||
|
||||
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;
|
||||
}
|
||||
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;
|
||||
|
||||
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;
|
||||
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 regexpA = a instanceof RegExp
|
||||
, regexpB = b instanceof RegExp;
|
||||
if (regexpA && regexpB) return a.toString() == b.toString();
|
||||
if (regexpA != regexpB) return false;
|
||||
keys = Object.keys(a);
|
||||
length = keys.length;
|
||||
if (length !== Object.keys(b).length) return false;
|
||||
|
||||
for (i = 0; i < keys.length; i++)
|
||||
for (i = length; i-- !== 0;)
|
||||
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;
|
||||
for (i = length; i-- !== 0;) {
|
||||
var 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;
|
||||
};
|
||||
|
||||
+35
-25
@@ -1,27 +1,27 @@
|
||||
{
|
||||
"_from": "fast-deep-equal@^1.0.0",
|
||||
"_id": "fast-deep-equal@1.0.0",
|
||||
"_from": "fast-deep-equal@^3.1.1",
|
||||
"_id": "fast-deep-equal@3.1.3",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-liVqO8l1WV6zbYLpkp0GDYk0Of8=",
|
||||
"_integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==",
|
||||
"_location": "/fast-deep-equal",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "fast-deep-equal@^1.0.0",
|
||||
"raw": "fast-deep-equal@^3.1.1",
|
||||
"name": "fast-deep-equal",
|
||||
"escapedName": "fast-deep-equal",
|
||||
"rawSpec": "^1.0.0",
|
||||
"rawSpec": "^3.1.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.0.0"
|
||||
"fetchSpec": "^3.1.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/ajv"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.0.0.tgz",
|
||||
"_shasum": "96256a3bc975595eb36d82e9929d060d893439ff",
|
||||
"_spec": "fast-deep-equal@^1.0.0",
|
||||
"_where": "/Users/cloyd/coderrr/odin/javascript-exercises/node_modules/ajv",
|
||||
"_resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
|
||||
"_shasum": "3a7d56b559d6cbc3eb512325244e619a65c6c525",
|
||||
"_spec": "fast-deep-equal@^3.1.1",
|
||||
"_where": "/home/michael/projects/javascript-exercises/node_modules/ajv",
|
||||
"author": {
|
||||
"name": "Evgeny Poberezkin"
|
||||
},
|
||||
@@ -32,19 +32,24 @@
|
||||
"deprecated": false,
|
||||
"description": "Fast deep equal",
|
||||
"devDependencies": {
|
||||
"benchmark": "^2.1.4",
|
||||
"coveralls": "^2.13.1",
|
||||
"deep-eql": "^2.0.2",
|
||||
"deep-equal": "^1.0.1",
|
||||
"eslint": "^4.0.0",
|
||||
"lodash": "^4.17.4",
|
||||
"mocha": "^3.4.2",
|
||||
"nano-equal": "^1.0.1",
|
||||
"nyc": "^11.0.2",
|
||||
"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",
|
||||
"shallow-equal-fuzzy": "0.0.2",
|
||||
"underscore": "^1.8.3"
|
||||
"react": "^16.12.0",
|
||||
"react-test-renderer": "^16.12.0",
|
||||
"sinon": "^9.0.2",
|
||||
"typescript": "^3.9.5"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts",
|
||||
"react.js",
|
||||
"react.d.ts",
|
||||
"es6/"
|
||||
],
|
||||
"homepage": "https://github.com/epoberezkin/fast-deep-equal#readme",
|
||||
"keywords": [
|
||||
"fast",
|
||||
@@ -69,10 +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-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-spec": "mocha spec/*.spec.js -R spec",
|
||||
"test-ts": "tsc --target ES5 --noImplicitAny index.d.ts"
|
||||
},
|
||||
"version": "1.0.0"
|
||||
"types": "index.d.ts",
|
||||
"version": "3.1.3"
|
||||
}
|
||||
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
rules:
|
||||
no-console: 0
|
||||
globals:
|
||||
describe: false
|
||||
it: false
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var equal = require('../index');
|
||||
var tests = require('./tests');
|
||||
var assert = require('assert');
|
||||
|
||||
|
||||
describe('equal', function() {
|
||||
tests.forEach(function (suite) {
|
||||
describe(suite.description, function() {
|
||||
suite.tests.forEach(function (test) {
|
||||
it(test.description, function() {
|
||||
assert.strictEqual(equal(test.value1, test.value2), test.equal);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
-320
@@ -1,320 +0,0 @@
|
||||
'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: '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 properties)',
|
||||
value1: {a: 1, b: '2', c: 3},
|
||||
value2: {a: 1, b: '2', d: 3},
|
||||
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: '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: '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
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
Reference in New Issue
Block a user