Function itr8ToObject

  • Turns an itr8 into an object. It is like Object.fromEntries, but it will work both for synchronous and asynchronous iterators

    Example

     // synchronous, same as Object.fromEntries(...)
    const myObj = pipe(
    itr8FromIterable([['a', 'value of A'], ['b', 'value of B'], ['c', 'value of C']]),
    itr8ToObject,
    ) // => {
    // a: 'value of A',
    // b: 'value of B',
    // c: 'value of C',
    // }

    // asynchronous
    await myObj2 = pipe(
    itr8FromIterable([['a', 'value of A'], ['b', 'value of B'], ['c', 'value of C']]),
    delay(100), // delay every element by 100 milliseconds
    itr8ToObject,
    ) // => {
    // a: 'value of A',
    // b: 'value of B',
    // c: 'value of C',
    // }

    Returns

    an array

    Type Parameters

    • TK extends string | number | symbol

    • TV

    Parameters

    • iterator: Iterator<[TK: string | number | symbol, TV: unknown], any, undefined> | AsyncIterator<[TK: string | number | symbol, TV: any], any, undefined>

    Returns Record<TK, TV> | Promise<Record<TK, TV>>

Generated using TypeDoc