UNPKG

681 BTypeScriptView Raw
1/**
2 * Take a fixed number of items from an iterable.
3 *
4 * @param object - The iterable object of interest.
5 *
6 * @param count - The number of items to take from the iterable.
7 *
8 * @returns An iterator which yields the specified number of items
9 * from the source iterable.
10 *
11 * #### Notes
12 * The returned iterator will exhaust early if the source iterable
13 * contains an insufficient number of items.
14 *
15 * #### Example
16 * ```typescript
17 * import { take } from '@lumino/algorithm';
18 *
19 * let stream = take([5, 4, 3, 2, 1, 0, -1], 3);
20 *
21 * Array.from(stream); // [5, 4, 3]
22 * ```
23 */
24export declare function take<T>(object: Iterable<T>, count: number): IterableIterator<T>;