is-equal
Are these two values conceptually equal?
Last updated 5 years ago by ljharb .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install is-equal 
SYNC missed versions from official npm registry.

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

Current Tags

  • 1.7.0                                ...           latest (a year ago)

26 Versions

  • 1.7.0                                ...           a year ago
  • 1.6.5 [deprecated]           ...           a year ago
  • 1.6.4                                ...           3 years ago
  • 1.6.3                                ...           3 years ago
  • 1.6.2                                ...           4 years ago
  • 1.6.1                                ...           5 years ago
  • 1.6.0                                ...           5 years ago
  • 1.5.5                                ...           8 years ago
  • 1.5.4                                ...           8 years ago
  • 1.5.3                                ...           8 years ago
  • 1.5.2                                ...           8 years ago
  • 1.5.1                                ...           9 years ago
  • 1.5.0                                ...           9 years ago
  • 1.4.2                                ...           9 years ago
  • 1.4.1                                ...           9 years ago
  • 1.4.0                                ...           9 years ago
  • 1.3.1                                ...           9 years ago
  • 1.3.0                                ...           9 years ago
  • 1.2.4                                ...           9 years ago
  • 1.2.3                                ...           10 years ago
  • 1.2.0                                ...           10 years ago
  • 1.1.1                                ...           10 years ago
  • 1.1.0                                ...           10 years ago
  • 1.0.0                                ...           10 years ago
  • 0.1.0                                ...           11 years ago
  • 0.0.0                                ...           11 years ago
Maintainers (2)
Downloads
Total 1
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (12)
Dev Dependencies (14)
Dependents (2)

© 2010 - cnpmjs.org x YWFE | Home | YWFE