Function toArray

  • Reads a set number of values from source, returning as an array. May contain empty values if desired values is not reached.

    After the limit is reached (or source completes), source is unsubscribed from.

    If no limit is set, it will read until source completes or maximumWait is reached. maximumWait is 10 seconds by default.

    Use toArrayOrThrow to throw if desired limit is not reached.

    // Read from `source` for 5 seconds
    const data = await toArray()(source);
    // Read 5 items from `source`
    const data = await toArray({ limit: 5 })(source);
    // Read for 10s
    const data = await toArray({ maximumWait: 10_1000 })(source);

    Type Parameters

    • V

    Parameters

    Returns Promise<(V | undefined)[]>