Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/phadej/reducemonoid
Reduce with an associative operation
https://github.com/phadej/reducemonoid
Last synced: about 7 hours ago
JSON representation
Reduce with an associative operation
- Host: GitHub
- URL: https://github.com/phadej/reducemonoid
- Owner: phadej
- Created: 2014-09-16T12:17:09.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2014-09-16T12:34:57.000Z (about 10 years ago)
- Last Synced: 2024-10-11T15:16:43.609Z (27 days ago)
- Language: JavaScript
- Size: 129 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# reducemonoid
> Reduce with an associative operation
[![Build Status](https://secure.travis-ci.org/phadej/reducemonoid.svg?branch=master)](http://travis-ci.org/phadej/reducemonoid)
[![NPM version](https://badge.fury.io/js/reducemonoid.svg)](http://badge.fury.io/js/reducemonoid)
[![Dependency Status](https://david-dm.org/phadej/reducemonoid.svg)](https://david-dm.org/phadej/reducemonoid)
[![devDependency Status](https://david-dm.org/phadej/reducemonoid/dev-status.svg)](https://david-dm.org/phadej/reducemonoid#info=devDependencies)
[![Code Climate](https://img.shields.io/codeclimate/github/phadej/reducemonoid.svg)](https://codeclimate.com/github/phadej/reducemonoid)## 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`