@phosphor/algorithm
Version:
PhosphorJS - Algorithms and Iterators
71 lines (70 loc) • 1.87 kB
TypeScript
import { IIterator } from './iter';
/**
* Create an iterator which repeats a value a number of times.
*
* @param value - The value to repeat.
*
* @param count - The number of times to repeat the value.
*
* @returns A new iterator which repeats the specified value.
*
* #### Example
* ```typescript
* import { repeat, toArray } from '@phosphor/algorithm';
*
* let stream = repeat(7, 3);
*
* toArray(stream); // [7, 7, 7]
* ```
*/
export declare function repeat<T>(value: T, count: number): IIterator<T>;
/**
* Create an iterator which yields a value a single time.
*
* @param value - The value to wrap in an iterator.
*
* @returns A new iterator which yields the value a single time.
*
* #### Example
* ```typescript
* import { once, toArray } from '@phosphor/algorithm';
*
* let stream = once(7);
*
* toArray(stream); // [7]
* ```
*/
export declare function once<T>(value: T): IIterator<T>;
/**
* An iterator which repeats a value a specified number of times.
*/
export declare class RepeatIterator<T> implements IIterator<T> {
/**
* Construct a new repeat iterator.
*
* @param value - The value to repeat.
*
* @param count - The number of times to repeat the value.
*/
constructor(value: T, count: number);
/**
* Get an iterator over the object's values.
*
* @returns An iterator which yields the object's values.
*/
iter(): IIterator<T>;
/**
* Create an independent clone of the iterator.
*
* @returns A new independent clone of the iterator.
*/
clone(): IIterator<T>;
/**
* Get the next value from the iterator.
*
* @returns The next value from the iterator, or `undefined`.
*/
next(): T | undefined;
private _value;
private _count;
}