Skip to content

throttleByteIterable

function throttleByteIterable(
source: AsyncIterable<Uint8Array<ArrayBufferLike>>,
throttle:
| BandwidthThrottle
| undefined,
signal?: AbortSignal): AsyncIterable<Uint8Array<ArrayBufferLike>>;

Defined in: src/transfers/BandwidthThrottle.ts:125

Wraps an async iterable of byte chunks so each chunk is released only after the throttle has admitted its byte count.

When throttle is undefined, the source iterable is returned unchanged.

ParameterTypeDescription
sourceAsyncIterable<Uint8Array<ArrayBufferLike>>Async iterable that produces byte chunks.
throttle| BandwidthThrottle | undefinedOptional throttle that paces chunk emission.
signal?AbortSignalOptional abort signal interrupting pending waits.

AsyncIterable<Uint8Array<ArrayBufferLike>>

Async generator emitting the original chunks at the throttled rate.