Adds check for valueOf/stringOf existence
When utilising this in a React context I was getting exceptions where a.valueOf / a.toString did not exist. The current logic didn't take this into account, leading to an exception when it tried to execute said functions.
I patched my local copy of your package with this fix and it worked great thereafter.
Here are the benchmark results post this patch:
fast-deep-equal x 280,216 ops/sec ±0.56% (90 runs sampled)
fast-deep-equal/es6 x 237,314 ops/sec ±0.55% (85 runs sampled)
fast-equals x 258,718 ops/sec ±0.58% (89 runs sampled)
nano-equal x 201,614 ops/sec ±0.54% (89 runs sampled)
shallow-equal-fuzzy x 154,959 ops/sec ±0.77% (90 runs sampled)
underscore.isEqual x 97,879 ops/sec ±0.53% (91 runs sampled)
lodash.isEqual x 40,880 ops/sec ±0.60% (89 runs sampled)
deep-equal x 196 ops/sec ±1.42% (58 runs sampled)
deep-eql x 44,681 ops/sec ±0.63% (90 runs sampled)
ramda.equals x 13,237 ops/sec ±0.83% (89 runs sampled)
util.isDeepStrictEqual x 59,043 ops/sec ±0.55% (89 runs sampled)
assert.deepStrictEqual x 503 ops/sec ±0.56% (87 runs sampled)
The fastest is fast-deep-equal
Coverage remained the same at 100.0% when pulling 193609ea02850ca90452d372f8154d213b1d0119 on ctrlplusb:master into a8e7172b6c411ec320d6045fd4afbd2abc1b4bde on epoberezkin:master.
I can't approve this, but wanted to say I think this looks good and worth merging.
There are edge cases where a and b do not have Object.prototype in its prototype chain, and a.valueOf() and a.toString() may not be implemented.
One suggestion is to add some unit tests to capture the requirement/need to test for a.valueOf and a.toString.
ie create some objects like Object.assign(Object.create(null), {a: 1, b: 2}) (which does not have .valueOf or .toString)
any progress?