AK-21/Graphite-Industrial-Intelligence
0
1# dequal [](https://github.com/lukeed/dequal/actions)2 3> A tiny (304B to 489B) utility to check for deep equality4 5This module supports comparison of all types, including `Function`, `RegExp`, `Date`, `Set`, `Map`, `TypedArray`s, `DataView`, `null`, `undefined`, and `NaN` values. Complex values (eg, Objects, Arrays, Sets, Maps, etc) are traversed recursively.6 7> **Important:**8> * key order **within Objects** does not matter9> * value order **within Arrays** _does_ matter10> * values **within Sets and Maps** use value equality11> * keys **within Maps** use value equality12 13 14## Install15 16```17$ npm install --save dequal18```19 20## Modes21 22There are two "versions" of `dequal` available:23 24#### `dequal`25> **Size (gzip):** 489 bytes<br>26> **Availability:** [CommonJS](https://unpkg.com/dequal/dist/index.js), [ES Module](https://unpkg.com/dequal/dist/index.mjs), [UMD](https://unpkg.com/dequal/dist/index.min.js)27 28#### `dequal/lite`29> **Size (gzip):** 304 bytes<br>30> **Availability:** [CommonJS](https://unpkg.com/dequal/lite/index.js), [ES Module](https://unpkg.com/dequal/lite/index.mjs)31 32| | IE9+ | Number | String | Date | RegExp | Object | Array | Class | Set | Map | ArrayBuffer | [TypedArray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray#TypedArray_objects) | [DataView](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView) |33|-|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|34| `dequal` | :x: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |35| `dequal/lite` | :+1: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :x: | :x: | :x: | :x: |36 37> <sup>**Note:** Table scrolls horizontally!</sup>38 39## Usage40 41```js42import { dequal } from 'dequal';43 44dequal(1, 1); //=> true45dequal({}, {}); //=> true46dequal('foo', 'foo'); //=> true47dequal([1, 2, 3], [1, 2, 3]); //=> true48dequal(dequal, dequal); //=> true49dequal(/foo/, /foo/); //=> true50dequal(null, null); //=> true51dequal(NaN, NaN); //=> true52dequal([], []); //=> true53dequal(54 [{ a:1 }, [{ b:{ c:[1] } }]],55 [{ a:1 }, [{ b:{ c:[1] } }]]56); //=> true57 58dequal(1, '1'); //=> false59dequal(null, undefined); //=> false60dequal({ a:1, b:[2,3] }, { a:1, b:[2,5] }); //=> false61dequal(/foo/i, /bar/g); //=> false62```63 64## API65 66### dequal(foo, bar)67Returns: `Boolean`68 69Both `foo` and `bar` can be of any type.<br>70A `Boolean` is returned indicating if the two were deeply equal.71 72 73## Benchmarks74 75> Running Node v10.13.076 77The benchmarks can be found in the [`/bench`](/bench) directory. They are separated into two categories:78 79* `basic` – compares an object comprised of `String`, `Number`, `Date`, `Array`, and `Object` values.80* `complex` – like `basic`, but adds `RegExp`, `Map`, `Set`, and `Uint8Array` values.81 82> **Note:** Only candidates that pass validation step(s) are listed. <br>For example, `fast-deep-equal/es6` handles `Set` and `Map` values, but uses _referential equality_ while those listed use _value equality_.83 84```85Load times:86 assert 0.109ms87 util 0.006ms88 fast-deep-equal 0.479ms89 lodash/isequal 22.826ms90 nano-equal 0.417ms91 dequal 0.396ms92 dequal/lite 0.264ms93 94Benchmark :: basic95 assert.deepStrictEqual x 325,262 ops/sec ±0.57% (94 runs sampled)96 util.isDeepStrictEqual x 318,812 ops/sec ±0.87% (94 runs sampled)97 fast-deep-equal x 1,332,393 ops/sec ±0.36% (93 runs sampled)98 lodash.isEqual x 269,129 ops/sec ±0.59% (95 runs sampled)99 nano-equal x 1,122,053 ops/sec ±0.36% (96 runs sampled)100 dequal/lite x 1,700,972 ops/sec ±0.31% (94 runs sampled)101 dequal x 1,698,972 ops/sec ±0.63% (97 runs sampled)102 103Benchmark :: complex104 assert.deepStrictEqual x 124,518 ops/sec ±0.64% (96 runs sampled)105 util.isDeepStrictEqual x 125,113 ops/sec ±0.24% (96 runs sampled)106 lodash.isEqual x 58,677 ops/sec ±0.49% (96 runs sampled)107 dequal x 345,386 ops/sec ±0.27% (96 runs sampled)108```109 110## License111 112MIT © [Luke Edwards](https://lukeed.com)113 