out of the box assert.deepCloseTo with configurable comparator
npm install deep-close-toNode's assert.deepEqual() but with configurable comparator.
The default comparator compares the absolute difference to be below an epsilon, suitable for floats.
`` js`
var closeTo = require('deep-close-to');
console.dir([
closeTo(
{ a : [ 2, 3 ], b : [ 4 ] },
{ a : [ 2, 3 ], b : [ 4 ] }
),
closeTo(
{ x : 36/5, y : [6] },
{ x : 72/10, y : 6 }
)
]);
` js`
var closeTo = require('deep-close-to')
Compare objects a and b, returning whether they are equal according to a
recursive equality algorithm.
If opts.strict is true, use strict equality (===) to compare leaf nodes.Number.EPSILON
The default is to compare their absolute difference to be below 0.0000001. was not used because numeric errors are often bigger than it.
With npm do:
``
npm install deep-close-to
With npm do:
```
npm test
MIT. Derived largely from substack's deep-equal.