UNPKG

1.56 kBTypeScriptView Raw
1import { Operator, Stream } from '../index';
2export declare class FlattenSeqOperator<T> implements Operator<Stream<T>, T> {
3 type: string;
4 ins: Stream<Stream<T>>;
5 private open;
6 private active;
7 private activeIL;
8 private seq;
9 out: Stream<T>;
10 constructor(ins: Stream<Stream<T>>);
11 _start(out: Stream<T>): void;
12 _stop(): void;
13 less(): void;
14 _n(s: Stream<T>): void;
15 _e(err: any): void;
16 _c(): void;
17}
18/**
19 * Flattens a "stream of streams", handling only one nested stream at a time,
20 * with no concurrency, but does not drop nested streams like `flatten` does.
21 *
22 * If the input stream is a stream that emits streams, then this operator will
23 * return an output stream which is a flat stream: emits regular events. The
24 * flattening happens sequentially and without concurrency. It works like this:
25 * when the input stream emits a nested stream, *flattenSequentially* will start
26 * imitating that nested one. When the next nested stream is emitted on the
27 * input stream, *flattenSequentially* will keep that in a buffer, and only
28 * start imitating it once the previous nested stream completes.
29 *
30 * In essence, `flattenSequentially` concatenates all nested streams.
31 *
32 * Marble diagram:
33 *
34 * ```text
35 * --+--------+-------------------------
36 * \ \
37 * \ ----1----2---3--|
38 * --a--b----c----d--|
39 * flattenSequentially
40 * -----a--b----c----d------1----2---3--
41 * ```
42 *
43 * @return {Stream}
44 */
45export default function flattenSequentially<T>(ins: Stream<Stream<T>>): Stream<T>;