Skip to main content

Variable: cycle()

const cycle: <Value>(iterable) => Iterable<Value>

Defined in: generators.d.ts:315

Returns an infinite iterable that repeatedly yields the values of iterable in iteration order.

WARNING: This function does not buffer the values of iterable for future cycles. It reiterates iterable each cycle.

Type Parameters

Value

Value

Parameters

iterable

Iterable<Value>

Returns

Iterable<Value>

Example

import { cycle, join, pipe, take } from 'lfi'

console.log(
pipe(
cycle([`sloth`, `lazy`]),
take(6),
join(`, `),
),
)
//=> sloth, lazy, sloth, lazy, sloth, lazy
Playground

Since

v0.0.1