Skip to content

Commit

Permalink
Merge pull request #33 from epoberezkin/v3
Browse files Browse the repository at this point in the history
v3 beta with ES6 Map, Set and Typed arrays support
  • Loading branch information
epoberezkin committed Jul 7, 2019
2 parents 8a9c22e + f4ed89a commit feddcc6
Show file tree
Hide file tree
Showing 13 changed files with 452 additions and 84 deletions.
1 change: 1 addition & 0 deletions .eslintrc.yml
Expand Up @@ -23,3 +23,4 @@ rules:
no-use-before-define: [ 2, nofunc ]
callback-return: 2
no-path-concat: 2
no-empty: 0
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -62,3 +62,6 @@ yarn.lock
.env

.DS_Store

# generated files
index.js
5 changes: 2 additions & 3 deletions .travis.yml
@@ -1,9 +1,8 @@
language: node_js
node_js:
- "4"
- "6"
- "8"
- "9"
- "10"
- "11"
- "12"
after_script:
- coveralls < coverage/lcov.info
43 changes: 32 additions & 11 deletions README.md
Expand Up @@ -6,6 +6,11 @@ The fastest 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)


This readme is for pre-release v3 with ES6 Map, Set and Typed arrays support.

See branch [v2](https://github.com/epoberezkin/fast-deep-equal/tree/v2) for the main version.


## Install

```bash
Expand All @@ -16,9 +21,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

Expand All @@ -27,28 +37,39 @@ 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
```


## 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 325,485 ops/sec ±0.57% (86 runs sampled)
fast-deep-equal/es6 x 261,338 ops/sec ±0.45% (89 runs sampled)
nano-equal x 231,064 ops/sec ±0.62% (88 runs sampled)
shallow-equal-fuzzy x 164,828 ops/sec ±0.87% (88 runs sampled)
underscore.isEqual x 91,247 ops/sec ±0.56% (88 runs sampled)
lodash.isEqual x 48,000 ops/sec ±0.48% (86 runs sampled)
deep-equal x 73,699 ops/sec ±0.55% (86 runs sampled)
deep-eql x 42,804 ops/sec ±0.45% (87 runs sampled)
ramda.equals x 15,119 ops/sec ±0.49% (87 runs sampled)
util.isDeepStrictEqual x 58,458 ops/sec ±0.56% (89 runs sampled)
assert.deepStrictEqual x 583 ops/sec ±0.47% (87 runs sampled)
The fastest is fast-deep-equal
```

To run benchmark (requires node.js 6+):

```bash
npm install
npm run build
node benchmark
```

Expand Down
8 changes: 5 additions & 3 deletions benchmark/index.js
Expand Up @@ -7,18 +7,20 @@ const suite = new Benchmark.Suite;


const equalPackages = {
'fast-deep-equal': require('../index'),
'fast-deep-equal': require('..'),
'fast-deep-equal/es6': require('../es6'),
'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; }
},
'ramda.equals': require('ramda').equals
}
};


Expand Down
10 changes: 10 additions & 0 deletions build.js
@@ -0,0 +1,10 @@
'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}));
try { fs.mkdirSync('./es6'); } catch(e) {}
fs.writeFileSync('./es6/index.js', jst({es6: true}));
55 changes: 0 additions & 55 deletions index.js

This file was deleted.

5 changes: 4 additions & 1 deletion package.json
Expand Up @@ -5,10 +5,12 @@
"main": "index.js",
"scripts": {
"eslint": "eslint *.js benchmark spec",
"build": "node build",
"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 eslint && npm run test-ts && npm run test-cov"
"test": "npm run build && npm run eslint && npm run test-ts && npm run test-cov",
"prepublish": "npm run build"
},
"repository": {
"type": "git",
Expand All @@ -30,6 +32,7 @@
"coveralls": "^2.13.1",
"deep-eql": "latest",
"deep-equal": "latest",
"dot": "^1.1.2",
"eslint": "^4.0.0",
"lodash": "latest",
"mocha": "^3.4.2",
Expand Down
2 changes: 2 additions & 0 deletions spec/.eslintrc.yml
@@ -1,3 +1,5 @@
env:
es6: true
rules:
no-console: 0
globals:
Expand Down

0 comments on commit feddcc6

Please sign in to comment.