UNPKG

1.51 kBTypeScriptView Raw
1import { IIterator, IterableOrArrayLike } from './iter';
2/**
3 * Take a fixed number of items from an iterable.
4 *
5 * @param object - The iterable or array-like object of interest.
6 *
7 * @param count - The number of items to take from the iterable.
8 *
9 * @returns An iterator which yields the specified number of items
10 * from the source iterable.
11 *
12 * #### Notes
13 * The returned iterator will exhaust early if the source iterable
14 * contains an insufficient number of items.
15 */
16export declare function take<T>(object: IterableOrArrayLike<T>, count: number): IIterator<T>;
17/**
18 * An iterator which takes a fixed number of items from a source.
19 */
20export declare class TakeIterator<T> implements IIterator<T> {
21 /**
22 * Construct a new take iterator.
23 *
24 * @param source - The iterator of interest.
25 *
26 * @param count - The number of items to take from the source.
27 */
28 constructor(source: IIterator<T>, count: number);
29 /**
30 * Get an iterator over the object's values.
31 *
32 * @returns An iterator which yields the object's values.
33 */
34 iter(): IIterator<T>;
35 /**
36 * Create an independent clone of the iterator.
37 *
38 * @returns A new independent clone of the iterator.
39 */
40 clone(): IIterator<T>;
41 /**
42 * Get the next value from the iterator.
43 *
44 * @returns The next value from the iterator, or `undefined`.
45 */
46 next(): T | undefined;
47 private _count;
48 private _source;
49}
50//# sourceMappingURL=take.d.ts.map
\No newline at end of file