Kit
Functions

mergeBytes

mergeBytes(byteArrays): Uint8Array

Concatenates an array of Uint8Arrays into a single Uint8Array. Reuses the original byte array when applicable.

Parameters

ParameterTypeDescription
byteArraysUint8Array<ArrayBufferLike>[]The array of byte arrays to concatenate.

Returns

Uint8Array

Example

const bytes1 = new Uint8Array([0x01, 0x02]);
const bytes2 = new Uint8Array([]);
const bytes3 = new Uint8Array([0x03, 0x04]);
const bytes = mergeBytes([bytes1, bytes2, bytes3]);
//    ^ [0x01, 0x02, 0x03, 0x04]

On this page