bytes.ts

Binary data conversion helpers.

Declarations
#

2 declarations

view source

format_bytes
#

bytes.ts view source

(n: number): string

Formats a byte count as a human-readable string.

n

byte count.

type number

returns

string

formatted string like '1.2 KB' or '3.4 MB'.

to_bytes
#

bytes.ts view source

(data: string | BufferSource): Uint8Array<ArrayBufferLike>

Converts string or binary data to a Uint8Array. Strings are UTF-8 encoded. Uint8Array inputs are returned as-is.

data

String or BufferSource to convert.

type string | BufferSource

returns

Uint8Array<ArrayBufferLike>

Uint8Array view of the data.

Imported by
#