is-equal

Are these two values conceptually equal?

is-equal downloads is-equal version is-equal license

is-equalSimilar Packages:

Npm Package Weekly Downloads Trend

3 Years
🌟 Show real-time usage chart on is-equal's README.md, just copy the code below.
## Usage Trend
[![Usage Trend of is-equal](https://npm-compare.com/img/npm-trend/THREE_YEARS/is-equal.png)](https://npm-compare.com/is-equal#timeRange=THREE_YEARS)

Cumulative GitHub Star Trend

🌟 Show GitHub stars trend chart on is-equal's README.md, just copy the code below.
## GitHub Stars Trend
[![GitHub Stars Trend of is-equal](https://npm-compare.com/img/github-trend/is-equal.png)](https://npm-compare.com/is-equal)

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
is-equal114,35260122 kB22 years agoMIT

README for is-equal

is-equal Version Badge

github actions coverage dependency status dev dependency status License Downloads

npm badge

Are these two values conceptually equal?

Example

var isEqual = require('is-equal');
var assert = require('assert');

var primitives = [true, false, undefined, 42, 'foo'];
primitives.forEach(function (primitive) {
	assert.equal(isEqual(primitive, primitive), true);
});
assert.equal(isEqual(/a/g, /a/g), true);
assert.equal(isEqual(/a/g, new RegExp('a', 'g')), true);
assert.equal(isEqual({ a: 2 }, { a: 2 }), true);
assert.equal(isEqual([1, [2, 3], 4], [1, [2, 3], 4]), true);
var timestamp = Date.now();
assert.equal(isEqual(new Date(timestamp), new Date(timestamp)), true);

Want to know why two values are not equal?

Will return an empty string if isEqual would return true - otherwise will return a non-empty string that hopefully explains the reasoning.

var whyNotEqual = require('is-equal/why');

assert.equal(whyNotEqual(1, 1), '');
assert.equal(
  whyNotEqual({ a: 1 }, { a: 2 }),
  'value at key "a" differs: numbers are different: 1 !== 2'
);

Tests

Simply clone the repo, npm install, and run npm test