Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Are these two values conceptually equal?

License

NotificationsYou must be signed in to change notification settings

inspect-js/is-equal

github actionscoveragedependency statusdev dependency statusLicenseDownloads

npm badge

Are these two values conceptually equal?

Example

varisEqual=require('is-equal');varassert=require('assert');varprimitives=[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,newRegExp('a','g')),true);assert.equal(isEqual({a:2},{a:2}),true);assert.equal(isEqual([1,[2,3],4],[1,[2,3],4]),true);vartimestamp=Date.now();assert.equal(isEqual(newDate(timestamp),newDate(timestamp)),true);

Want to knowwhy two values are not equal?

Will return an empty string ifisEqual would returntrue - 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 runnpm test

About

Are these two values conceptually equal?

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Contributors7


[8]ページ先頭

©2009-2025 Movatter.jp