Skip to content

Commit 3986520

Browse files
📚 docs(README): Add code sample. Remove WIP warning.
1 parent b7fa76a commit 3986520

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

README.md

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,35 @@
44
Iterable reducers for JavaScript.
55
See [docs](https://iterable-iterator.github.io/reduce/index.html).
66

7-
> :building_construction: Caveat emptor! This is work in progress. Code may be
8-
> working. Documentation may be present. Coherence may be. Maybe.
9-
107
> :warning: Depending on your environment, the code may require
118
> `regeneratorRuntime` to be defined, for instance by importing
129
> [regenerator-runtime/runtime](https://www.npmjs.com/package/regenerator-runtime).
1310
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+
1436
[![License](https://img.shields.io/github/license/iterable-iterator/reduce.svg)](https://raw.githubusercontent.com/iterable-iterator/reduce/main/LICENSE)
1537
[![Version](https://img.shields.io/npm/v/@iterable-iterator/reduce.svg)](https://www.npmjs.org/package/@iterable-iterator/reduce)
1638
[![Tests](https://img.shields.io/github/workflow/status/iterable-iterator/reduce/ci:test?event=push&label=tests)](https://github.com/iterable-iterator/reduce/actions/workflows/ci:test.yml?query=branch:main)

0 commit comments

Comments
 (0)