Skip to content

Commit

Permalink
[New] add “whyNotEqual” at require(‘is-equal/why’) to provide an in…
Browse files Browse the repository at this point in the history
…equality reason.
  • Loading branch information
ljharb committed Feb 16, 2016
1 parent 8f47efa commit fd7a11d
Show file tree
Hide file tree
Showing 7 changed files with 962 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .jscs.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@

"disallowArrowFunctions": true,

"disallowMultiLineTernary": true,
"disallowMultiLineTernary": false,

"validateOrderInObjectKeys": "asc-insensitive",

Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ 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(isEqual(1, 1), '');
assert.equal(
isEqual({ 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`

Expand Down
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
"main": "index.js",
"scripts": {
"test": "npm run lint && npm run tests-only && npm run security",
"tests-only": "npm run test:native && npm run test:shimmed && npm run test:corejs",
"test:native": "node test/native.js",
"test:shimmed": "node test/shimmed.js",
"test:corejs": "node test/corejs.js",
"coverage": "covert test/native.js",
"tests-only": "npm run test:native && npm run test:why && npm run test:shimmed && npm run test:corejs",
"test:native": "node test/native",
"test:why": "node test/why",
"test:shimmed": "node test/shimmed",
"test:corejs": "node test/corejs",
"coverage": "covert test/native test/why",
"coverage-quiet": "covert test/native.js --quiet",
"lint": "npm run jscs && npm run eslint",
"jscs": "jscs *.js test/*.js",
Expand Down
2 changes: 2 additions & 0 deletions test/corejs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@

require('core-js');

require('./why');

require('./native');
2 changes: 2 additions & 0 deletions test/shimmed.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@

require('es6-shim');

require('./why');

require('./native');
Loading

0 comments on commit fd7a11d

Please sign in to comment.