Functions
padBytes
padBytes(
bytes
,length
):ReadonlyUint8Array
|Uint8Array
<ArrayBufferLike
>
Pads a Uint8Array
with zeroes to the specified length.
If the array is longer than the specified length, it is returned as-is.
Parameters
Parameter | Type | Description |
---|---|---|
bytes | ReadonlyUint8Array | Uint8Array <ArrayBufferLike > | The byte array to pad. |
length | number | The desired length of the byte array. |
Returns
ReadonlyUint8Array
| Uint8Array
<ArrayBufferLike
>
Examples
Adds zeroes to the end of the byte array to reach the desired length.
Returns the original byte array if it is already at the desired length.