UNPKG

1.05 kBPlain TextView Raw
1// Copyright (c) Jupyter Development Team.
2// Distributed under the terms of the Modified BSD License.
3/*-----------------------------------------------------------------------------
4| Copyright (c) 2014-2017, PhosphorJS Contributors
5|
6| Distributed under the terms of the BSD 3-Clause License.
7|
8| The full license is in the file LICENSE, distributed with this software.
9|----------------------------------------------------------------------------*/
10
11/**
12 * Chain together several iterables.
13 *
14 * @deprecated
15 *
16 * @param objects - The iterable objects of interest.
17 *
18 * @returns An iterator which yields the values of the iterables
19 * in the order in which they are supplied.
20 *
21 * #### Example
22 * ```typescript
23 * import { chain } from '@lumino/algorithm';
24 *
25 * let data1 = [1, 2, 3];
26 * let data2 = [4, 5, 6];
27 *
28 * let stream = chain(data1, data2);
29 *
30 * Array.from(stream); // [1, 2, 3, 4, 5, 6]
31 * ```
32 */
33export function* chain<T>(...objects: Iterable<T>[]): IterableIterator<T> {
34 for (const object of objects) {
35 yield* object;
36 }
37}