Skip to content
forked from lukeed/dequal

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

License

Notifications You must be signed in to change notification settings

szepeviktor/dequal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dequal Build Status

A tiny (247B) utility to check for deep equality

This module supports comparison of all types, including Function, RegExp, Date, null, undefined, and NaN values.
Objects and Arrays are traversed recursively.

Please note that key order within Objects does not affect the result.
However, the value order within Arrays does matter.

This module exposes two module definitions:

  • ES Module: dist/dequal.mjs
  • CommonJS: dist/dequal.js
  • UMD: dist/dequal.min.js

Install

$ npm install --save dequal

Usage

const dequal = require('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 on any type.
A Boolean is returned indicating if the two were deeply equal.

License

MIT © Luke Edwards

About

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

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Languages

  • JavaScript 100.0%