mattphillips / deep-object-diff

Deep diffs two objects, including nested structures of arrays and objects, and returns the difference. ❄️
https://www.npmjs.com/package/deep-object-diff
MIT License
1.05k stars 89 forks source link

remove usage of the 'reduce...spread' pattern #47

Closed schester44 closed 3 years ago

schester44 commented 5 years ago

This is a PR in response to #46 . It aims to improve the speed of the package by removing the usage of the 'reduce...spread' pattern, in favor of traditional for loops.

Benchmark.js stats

added#original x 533,358 ops/sec ±0.70% (92 runs sampled) added#new x 1,114,933 ops/sec ±0.63% (94 runs sampled)

updated#original x 391,597 ops/sec ±0.97% (91 runs sampled) updated#new x 1,057,258 ops/sec ±0.47% (95 runs sampled)

deleted#original x 1,299,890 ops/sec ±0.54% (94 runs sampled) deleted#new x 1,981,737 ops/sec ±1.09% (90 runs sampled)

detailed#original x 203,221 ops/sec ±0.60% (93 runs sampled) detailed#new x 357,716 ops/sec ±0.36% (85 runs sampled)

diff#original x 244,553 ops/sec ±0.50% (91 runs sampled) diff#new x 855,466 ops/sec ±0.97% (92 runs sampled)

Reference https://www.richsnapp.com/blog/2019/06-09-reduce-spread-anti-pattern

coveralls commented 5 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling e6dd6f17ff9ed0dca7be31d0f44edbaa7c219ff8 on schester44:master into 6296889cfc0e54f08b0077460c9bf75f2febfa9f on mattphillips:master.