Skip to content

uint8ArrayToAsyncIterable

function uint8ArrayToAsyncIterable(data, chunkSize): AsyncIterable<Uint8Array<ArrayBufferLike>>;

Defined in: packages/synapse-core/src/piece.ts:353

Convert Uint8Array to async iterable with optimal chunk size.

Uses 2048-byte chunks for better hasher performance (determined by manual testing with Node.js; this will likely vary by environment). This may not be optimal for the streaming upload case, so further tuning may be needed to find the best balance between hasher performance and upload chunk size.

ParameterTypeDefault valueDescription
dataUint8ArrayundefinedUint8Array to convert
chunkSizenumber2048Size of chunks (default 2048)

AsyncIterable<Uint8Array<ArrayBufferLike>>

AsyncIterable yielding chunks