You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: APIDOC.md
+25-7Lines changed: 25 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,27 +7,45 @@ Download the [latest release](https://github.com/winterbe/sequency/releases) fro
7
7
```bash
8
8
npm install sequency
9
9
```
10
+
or
11
+
```bash
12
+
yarn add sequency
13
+
```
10
14
11
-
Or [try Sequency](https://npm.runkit.com/sequency) right in your browser.
15
+
### How Sequency works
12
16
13
-
### How sequences works
17
+
Sequency is centered around the interface [Sequence](https://winterbe.github.io/sequency/interfaces/Sequence.html) to process any kind of iterable data such as arrays, maps and sets.
14
18
15
-
Sequency is centered around a single class `Sequence` to process any kind of iterable data. The API is inspired by Kotlin [Sequences](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.sequences/-sequence/index.html).
19
+
The interface `Sequence` provides a fluent functional API consisting of intermediate and terminal operations. Intermediate functions return a new sequence, thus enabling method chaining while terminal functions return an arbitrary result. You can explore all available `Sequence` operations by navigating to the [Sequence](https://winterbe.github.io/sequency/interfaces/Sequence.html) interface.
16
20
17
-
Each `Sequence` provides a fluent functional API consisting of intermediate and terminal operations. Intermediate functions return a new sequence, thus enabling method chaining while terminal functions return an arbitrary result. You can explore all available `Sequence` operations on this website by using the site navigation to the right.
21
+
### Creating Sequences from your data
18
22
19
23
Sequences can be created with one of the following functions:
-`sequenceOf` accepts one or many values and returns a new sequence.
26
30
-`asSequence` accepts an iterable (e.g. an array, set or map) and returns a new sequence.
27
31
-`emptySequence` returns a new empty sequence.
32
+
-`generateSequence` creates a sequence from the results of the given generator function.
33
+
34
+
### Code sample
35
+
36
+
```js
37
+
import {asSequence} from"sequency";
38
+
39
+
constnumbers= [1, 2, 3, 4, 5];
28
40
29
-
Sequences are lazily evaluated to avoid examining all of the input data when it's not necessary. Sequences always perform the minimal amount of operations to gain results. E.g. in a `filter - map - find` sequence both `map` and `find` are executed just one time before returning the single result.
0 commit comments