UNPKG

735 BTypeScriptView Raw
1import { Stream } from '../index';
2/**
3 * Group consecutive pairs of events as arrays. Each array has two items.
4 *
5 * Marble diagram:
6 *
7 * ```text
8 * ---1---2-----3-----4-----5--------|
9 * pairwise
10 * -------[1,2]-[2,3]-[3,4]-[4,5]----|
11 * ```
12 *
13 * Example:
14 *
15 * ```js
16 * import pairwise from 'xstream/extra/pairwise'
17 *
18 * const stream = xs.of(1, 2, 3, 4, 5, 6).compose(pairwise)
19 *
20 * stream.addListener({
21 * next: i => console.log(i),
22 * error: err => console.error(err),
23 * complete: () => console.log('completed')
24 * })
25 * ```
26 *
27 * ```text
28 * > [1,2]
29 * > [2,3]
30 * > [3,4]
31 * > [4,5]
32 * > [5,6]
33 * > completed
34 * ```
35 *
36 * @return {Stream}
37 */
38export default function pairwise<T>(ins: Stream<T>): Stream<[T, T]>;