Skip to content

Commit

Permalink
fix(extras): fix inclusion of new operator flattenConcurrentlyAtMost
Browse files Browse the repository at this point in the history
  • Loading branch information
staltz committed Jan 10, 2019
1 parent 75ca7de commit 089e661
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 10 deletions.
49 changes: 49 additions & 0 deletions EXTRA_DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- [`dropRepeats`](#dropRepeats) (operator)
- [`dropUntil`](#dropUntil) (operator)
- [`flattenConcurrently`](#flattenConcurrently) (operator)
- [`flattenConcurrentlyAtMost`](#flattenConcurrentlyAtMost) (operator)
- [`flattenSequentially`](#flattenSequentially) (operator)
- [`fromDiagram`](#fromDiagram) (factory)
- [`fromEvent`](#fromEvent) (factory)
Expand Down Expand Up @@ -358,6 +359,54 @@ Marble diagram:

- - -

### <a id="flattenConcurrentlyAtMost"></a> `flattenConcurrentlyAtMost()`

Flattens a "stream of streams", handling multiple concurrent nested streams
simultaneously, up to some limit `n`.

If the input stream is a stream that emits streams, then this operator will
return an output stream which is a flat stream: emits regular events. The
flattening happens concurrently, up to the configured limit. It works like
this: when the input stream emits a nested stream,
*flattenConcurrentlyAtMost* will start imitating that nested one. When the
next nested stream is emitted on the input stream,
*flattenConcurrentlyAtMost* will check to see how many streams it is connected
to. If it is connected to a number of streams less than the limit, it will also
imitate that new one, but will continue to imitate the previous nested streams
as well.

If the limit has already been reached, *flattenConcurrentlyAtMost* will put the
stream in a queue. When any of the streams it is listening to completes, a stream
is taken out of the queue and `flattenConcurrentlyAtMost` will connect to it.

This process continues until the metastream completes and there are no more
connected streams or streams in the queue.

Marble diagrams:

```text
--+--------+---------------
\ \
\ ----1----2---3--|
--a--b----c----|
flattenConcurrentlyAtMost(1)
-----a--b----c-1----2---3--|
```

```text
--+---+---+-|
\ \ \
\ \ ---fgh----i-----jh--|
\ -----1----2----3--|
---a--b-----c--|
flattenConcurrentlyAtMost(2)
---------a--b-1---c2--i-3------fgh----i-----jh--|
```

#### Returns: Stream

- - -

### <a id="flattenSequentially"></a> `flattenSequentially()`

Flattens a "stream of streams", handling only one nested stream at a time,
Expand Down
13 changes: 3 additions & 10 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@
"noEmitHelpers": false,
"target": "ES5",
"outDir": "./",
"lib": [
"dom",
"es5",
"es2015.collection",
"es2015.promise"
]
"lib": ["dom", "es5", "es2015.collection", "es2015.promise"]
},
"formatCodeOptions": {
"indentSize": 2,
Expand All @@ -32,6 +27,7 @@
"src/extra/dropUntil.ts",
"src/extra/flattenSequentially.ts",
"src/extra/flattenConcurrently.ts",
"src/extra/flattenConcurrentlyAtMost.ts",
"src/extra/fromDiagram.ts",
"src/extra/fromEvent.ts",
"src/extra/pairwise.ts",
Expand All @@ -41,10 +37,7 @@
"src/extra/tween.ts",
"src/index.ts"
],
"filesGlob": [
"typings/index.d.ts",
"src/**/*.ts"
],
"filesGlob": ["typings/index.d.ts", "src/**/*.ts"],
"atom": {
"rewriteTsconfig": true
}
Expand Down

0 comments on commit 089e661

Please sign in to comment.