Function: repeat()
repeat<
ElementType>(value:ElementType,count:number):IterableIterator<ElementType>
Defined in: projects/utilities/packages/iterator-utilities/src/lib/repeat.ts:22
Creates an iterable that repeats the input iterable count times.
Type Parameters
| Type Parameter |
|---|
ElementType |
Parameters
| Parameter | Type | Description |
|---|---|---|
value | ElementType | The value to be repeated. |
count | number | The number of times to repeat the value. |
Returns
IterableIterator<ElementType>
Example
import { repeat } from '@sapphire/iterator-utilities';
const iterator = repeat('Hello, world!', 3);
console.log([...iterator]);
// Output: ['Hello, world!', 'Hello, world!', 'Hello, world!']
Remarks
This function does not clone value, it will be repeated as a reference.