1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 5x 5x 12x 7x 7x 4x 12x 24x 5x 2x 5x 10x 5x | import { Collection, asIterable } from './utils' import Sequence from './Sequence' function repeat<T>(collection: Collection<T>, times: number = Infinity) { const iterable = asIterable(collection) return new Sequence(function* () { for(let i = 0; i < times; i++) { for(const value of iterable) { yield value } } }) } export function repeatValue<T>(value: T, times: number = Infinity) { return new Sequence(function* () { for(let i = 0; i < times; i++) { yield value } }) } export default repeat |