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(iterable: Iterable<unknown>): Iterable<string>
stringifyJSONStreamAsync
function stringifyNDJSONStreamAsync(iterable: AsyncIterable<unknown>): AsyncIterable<string>
stringifyNDJSONStream
function stringifyNDJSONStream(iterable: Iterable<unknown>): Iterable<string>
stringifyNDJSONStreamAsync
function stringifyNDJSONStreamAsync(iterable: AsyncIterable<unknown>): AsyncIterable<string>
sse
interface IMessage {
event?: string
data: string
id?: string
retry?: number
}
function sse(message: IMessage): Iterable<string>