npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dequal

v2.0.3

Published

A tiny (304B to 489B) utility for check for deep equality

Downloads

63,626,624

Readme

dequal CI

A tiny (304B to 489B) utility to check for deep equality

This module supports comparison of all types, including Function, RegExp, Date, Set, Map, TypedArrays, DataView, null, undefined, and NaN values. Complex values (eg, Objects, Arrays, Sets, Maps, etc) are traversed recursively.

Important:

  • key order within Objects does not matter
  • value order within Arrays does matter
  • values within Sets and Maps use value equality
  • keys within Maps use value equality

Install

$ npm install --save dequal

Modes

There are two "versions" of dequal available:

dequal

Size (gzip): 489 bytes Availability: CommonJS, ES Module, UMD

dequal/lite

Size (gzip): 304 bytes Availability: CommonJS, ES Module

| | IE9+ | Number | String | Date | RegExp | Object | Array | Class | Set | Map | ArrayBuffer | TypedArray | DataView | |-|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:| | 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: | | 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: |

Note: Table scrolls horizontally!

Usage

import { dequal } from 'dequal';

dequal(1, 1); //=> true
dequal({}, {}); //=> true
dequal('foo', 'foo'); //=> true
dequal([1, 2, 3], [1, 2, 3]); //=> true
dequal(dequal, dequal); //=> true
dequal(/foo/, /foo/); //=> true
dequal(null, null); //=> true
dequal(NaN, NaN); //=> true
dequal([], []); //=> true
dequal(
  [{ a:1 }, [{ b:{ c:[1] } }]],
  [{ a:1 }, [{ b:{ c:[1] } }]]
); //=> true

dequal(1, '1'); //=> false
dequal(null, undefined); //=> false
dequal({ a:1, b:[2,3] }, { a:1, b:[2,5] }); //=> false
dequal(/foo/i, /bar/g); //=> false

API

dequal(foo, bar)

Returns: Boolean

Both foo and bar can be of any type. A Boolean is returned indicating if the two were deeply equal.

Benchmarks

Running Node v10.13.0

The benchmarks can be found in the /bench directory. They are separated into two categories:

  • basic – compares an object comprised of String, Number, Date, Array, and Object values.
  • complex – like basic, but adds RegExp, Map, Set, and Uint8Array values.

Note: Only candidates that pass validation step(s) are listed. For example, fast-deep-equal/es6 handles Set and Map values, but uses referential equality while those listed use value equality.

Load times:
  assert             0.109ms
  util               0.006ms
  fast-deep-equal    0.479ms
  lodash/isequal    22.826ms
  nano-equal         0.417ms
  dequal             0.396ms
  dequal/lite        0.264ms

Benchmark :: basic
  assert.deepStrictEqual  x    325,262 ops/sec ±0.57% (94 runs sampled)
  util.isDeepStrictEqual  x    318,812 ops/sec ±0.87% (94 runs sampled)
  fast-deep-equal         x  1,332,393 ops/sec ±0.36% (93 runs sampled)
  lodash.isEqual          x    269,129 ops/sec ±0.59% (95 runs sampled)
  nano-equal              x  1,122,053 ops/sec ±0.36% (96 runs sampled)
  dequal/lite             x  1,700,972 ops/sec ±0.31% (94 runs sampled)
  dequal                  x  1,698,972 ops/sec ±0.63% (97 runs sampled)

Benchmark :: complex
  assert.deepStrictEqual  x    124,518 ops/sec ±0.64% (96 runs sampled)
  util.isDeepStrictEqual  x    125,113 ops/sec ±0.24% (96 runs sampled)
  lodash.isEqual          x     58,677 ops/sec ±0.49% (96 runs sampled)
  dequal                  x    345,386 ops/sec ±0.27% (96 runs sampled)

License

MIT © Luke Edwards