1 | import { IIterator } from './iter';
|
2 | /**
|
3 | * Create an iterator which repeats a value a number of times.
|
4 | *
|
5 | * @param value - The value to repeat.
|
6 | *
|
7 | * @param count - The number of times to repeat the value.
|
8 | *
|
9 | * @returns A new iterator which repeats the specified value.
|
10 | *
|
11 | * #### Example
|
12 | * ```typescript
|
13 | * import { repeat, toArray } from '@phosphor/algorithm';
|
14 | *
|
15 | * let stream = repeat(7, 3);
|
16 | *
|
17 | * toArray(stream); // [7, 7, 7]
|
18 | * ```
|
19 | */
|
20 | export declare function repeat<T>(value: T, count: number): IIterator<T>;
|
21 | /**
|
22 | * Create an iterator which yields a value a single time.
|
23 | *
|
24 | * @param value - The value to wrap in an iterator.
|
25 | *
|
26 | * @returns A new iterator which yields the value a single time.
|
27 | *
|
28 | * #### Example
|
29 | * ```typescript
|
30 | * import { once, toArray } from '@phosphor/algorithm';
|
31 | *
|
32 | * let stream = once(7);
|
33 | *
|
34 | * toArray(stream); // [7]
|
35 | * ```
|
36 | */
|
37 | export declare function once<T>(value: T): IIterator<T>;
|
38 | /**
|
39 | * An iterator which repeats a value a specified number of times.
|
40 | */
|
41 | export declare class RepeatIterator<T> implements IIterator<T> {
|
42 | /**
|
43 | * Construct a new repeat iterator.
|
44 | *
|
45 | * @param value - The value to repeat.
|
46 | *
|
47 | * @param count - The number of times to repeat the value.
|
48 | */
|
49 | constructor(value: T, count: number);
|
50 | /**
|
51 | * Get an iterator over the object's values.
|
52 | *
|
53 | * @returns An iterator which yields the object's values.
|
54 | */
|
55 | iter(): IIterator<T>;
|
56 | /**
|
57 | * Create an independent clone of the iterator.
|
58 | *
|
59 | * @returns A new independent clone of the iterator.
|
60 | */
|
61 | clone(): IIterator<T>;
|
62 | /**
|
63 | * Get the next value from the iterator.
|
64 | *
|
65 | * @returns The next value from the iterator, or `undefined`.
|
66 | */
|
67 | next(): T | undefined;
|
68 | private _value;
|
69 | private _count;
|
70 | }
|