Install
npm install --save extra-generator
yarn add extra-generator
API
of
function of<T>(val: T): Iterable<T>
of(1)
repeat
function repeat<T>(val: T, times: number = Infinity): Iterable<T>
repeat(1)
repeat(1, 3)
repeat(1, 0)
countdown
function countdown(begin: number, end: number): Iterable<number>
countdown(2, -2)
countdown(1, 1)
countdown(0, 1)
countup
function countup(begin: number, end: number): Iterable<number>
countup(-2, 2)
countup(1, 1)
countup(1, 0)
range
function range(start: number, end: number, step: number = 1): Iterable<number>
range(1, 1)
range(-2, 2)
range(2, -2)
range(1, -1, 0.5)
range(2, -2, 0)
range(2, -2, -0.5)
stringifyJSONStream
function stringifyJSONStream<T>(iterable: Iterable<T>): Iterable<string>
stringifyJSONStreamAsync
function stringifyNDJSONStreamAsync<T>(iterable: AsyncIterable<T>): AsyncIterable<string>
stringifyNDJSONStream
function stringifyNDJSONStream<T>(iterable: Iterable<T>): Iterable<string>
stringifyNDJSONStreamAsync
function stringifyNDJSONStreamAsync<T>(iterable: AsyncIterable<T>): AsyncIterable<string>
sse
interface IMessage {
event?: string
data: string
id?: string
retry?: number
}
function sse(message: IMessage): Iterable<string>
ReusableIterable
class ReusableIterable<T> implements IReusableIterable<T> {
get done(): boolean | undefined
constructor(iterable: Iterable<T>)
close(): void
}
ReusableAsyncIterable
class ReusableAsyncIterable<T> implements IReusableAsyncIterable<T> {
get done(): boolean | undefined
constructor(iterable: AsyncIterable<T>)
close(): Promise<void>
}