• Stars
    star
    1,863
  • Rank 24,881 (Top 0.5 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 7 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The fastest deep equality check with Date, RegExp and ES6 Map, Set and typed arrays support

fast-deep-equal

The fastest deep equal with ES6 Map, Set and Typed arrays support.

Build Status npm Coverage Status

Install

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

var equal = require('fast-deep-equal');
console.log(equal({foo: 'bar'}, {foo: 'bar'})); // true

To support ES6 Maps, Sets and Typed arrays equality use:

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):

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+):

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 - 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. Tidelift will coordinate the fix and disclosure. Please do NOT report security vulnerability via GitHub issues.

License

MIT

More Repositories

1

json-schema-traverse

Traverse JSON Schema passing each schema object to callback
JavaScript
96
star
2

json-source-map

Parse/stringify JSON and provide source-map for JSON-pointers to all nodes - supports BigInt, Maps, Sets and Typed arrays
JavaScript
69
star
3

twitter-codeigniter

CodeIgniter Twitter OAuth library
PHP
17
star
4

node-babel

Babel require hook with whitelist of transpilers for es6 features that node 0.12 with harmony flag does not support
JavaScript
11
star
5

WhoYouMeet.com-source-code

http://WhoYouMeet.com is a web app that "helps you to meet more people you need" (and fewer people you don't :)
PHP
10
star
6

gh-pages-generator

Multi-page site generator converting markdown files to github pages
JavaScript
9
star
7

json-schema-usage-problems

Public forum to collect real world schemas and to discuss JSON Schema spec problems
JavaScript
7
star
8

sacjs

Set Associative Cache
JavaScript
6
star
9

poberezkin.com

My blog
CSS
6
star
10

firebase-poll

Simple poll app using Firebase API
HTML
4
star
11

extended-json-patch

Extended JSON Patch specification
4
star
12

json-schema-consolidate

Adapter to different JSON-schema validators
JavaScript
4
star
13

freer-indexed

Freer parameterized monads
Haskell
3
star
14

schemabin

JSON-Schema web playground
JavaScript
3
star
15

tutsplus-json-schema

Validating Data With JSON-Schema
JavaScript
3
star
16

dotfiles

dotfiles
Emacs Lisp
2
star
17

phantom-chai

Chai for phantomjs scripts
JavaScript
2
star
18

koa-dot

doT for koa with caching and layout support
JavaScript
2
star
19

json-schema-compiler

JSON-schema compiler
JavaScript
2
star
20

atm-state-machine

atm-state-machine
Haskell
2
star
21

advanced-haskell-types

Advanced haskell types
Haskell
2
star
22

haskell-template

Haskell repo template
Haskell
2
star
23

elevator-state-machine

Modeling state machine with dependent types - code for post
Haskell
2
star
24

koa-typed-body-parser

Uses Ajv compiled parsers based on JTD schemas to parse koa request JSON body
TypeScript
2
star
25

vscode-dot-templates

VS Code Syntax highlighting for doT templates
2
star
26

srvc

Micro-services framework for node.js
JavaScript
1
star
27

array-list

IsList instances of Array for OverloadedLists extension
Haskell
1
star
28

interact

Instantly create REPL from any function, stateless or with state
Haskell
1
star
29

test-validators

Test validators compatibility with JSON Schema
JavaScript
1
star
30

protocol

Model distributed system as type-level multi-party protocol.
Haskell
1
star
31

fjv

Fake JSON-Schema validator
JavaScript
1
star
32

ajv-merge-refs

Resolve references in JSON schemas
1
star