|
4 | 4 | Iterable reducers for JavaScript. |
5 | 5 | See [docs](https://iterable-iterator.github.io/reduce/index.html). |
6 | 6 |
|
7 | | -> :building_construction: Caveat emptor! This is work in progress. Code may be |
8 | | -> working. Documentation may be present. Coherence may be. Maybe. |
9 | | -
|
10 | 7 | > :warning: Depending on your environment, the code may require |
11 | 8 | > `regeneratorRuntime` to be defined, for instance by importing |
12 | 9 | > [regenerator-runtime/runtime](https://www.npmjs.com/package/regenerator-runtime). |
13 | 10 |
|
| 11 | +```js |
| 12 | +import {range} from '@iterable-iterator/range'; |
| 13 | +import {reduce} from '@iterable-iterator/reduce'; |
| 14 | +import {mul, add} from '@functional-abstraction/operator'; |
| 15 | + |
| 16 | +reduce( mul , range( 2 , 6 ) , 1 ) ; // 120 |
| 17 | +reduce( add , range( 2 , 6 ) , 1 ) ; // 15 |
| 18 | + |
| 19 | +import {sum} from '@iterable-iterator/reduce'; |
| 20 | +sum( range( 6 ) ) ; // 15 |
| 21 | + |
| 22 | +import {any, all, some} from '@iterable-iterator/reduce'; |
| 23 | +any( [ false* , true , ... ] ) ; // T |
| 24 | +any( [ false* ] ) ; // F |
| 25 | +all( [ true* , false , ... ] ) ; // F |
| 26 | +all( [ true* ] ) ; // T |
| 27 | +some( [ true , true , false , true , ... ] , 3 ) ; // T |
| 28 | +some( [ true , false , true , false* ] , 3 ) ; // F |
| 29 | + |
| 30 | +import {increasing, decreasing} from "@total-order/primitive" ; |
| 31 | +import {min, max} from '@iterable-iterator/reduce'; |
| 32 | +min( increasing , [ 2 , 1 , 3 ] ) ; // 1 |
| 33 | +max( increasing , [ 2 , 1 , 3 ] ) ; // 3 |
| 34 | +``` |
| 35 | + |
14 | 36 | [](https://raw.githubusercontent.com/iterable-iterator/reduce/main/LICENSE) |
15 | 37 | [](https://www.npmjs.org/package/@iterable-iterator/reduce) |
16 | 38 | [](https://github.com/iterable-iterator/reduce/actions/workflows/ci:test.yml?query=branch:main) |
|
0 commit comments