reducemonoid

0.1.1 • Public • Published

reducemonoid

Reduce with an associative operation

Build Status NPM version Dependency Status devDependency Status Code Climate

Why

For some reason reducemonoid is faster than reduce or reduceRight:

100 elements
reducemonoid x 407 ops/sec ±6.55% (82 runs sampled)
native reduce x 190 ops/sec ±1.02% (90 runs sampled)
native reduceRight x 168 ops/sec ±5.58% (73 runs sampled)
underscore reduce x 162 ops/sec ±6.12% (82 runs sampled)
underscore reduceRight x 164 ops/sec ±7.45% (78 runs sampled)
lodash reduce x 188 ops/sec ±1.45% (89 runs sampled)
lodash reduceRight x 189 ops/sec ±2.72% (90 runs sampled)
Fastest is reducemonoid

API

  • reduceMonoid(arr: Array a, operation: a -> a -> a, unit: a): a
  • reduceMonoid.reduceSemigroup(arr: NonEmptyArray a, operation: a -> a -> a): a

Package Sidebar

Install

npm i reducemonoid

Weekly Downloads

4

Version

0.1.1

License

MIT

Last publish

Collaborators

  • phadej