bytes.ts

Binary data conversion helpers.

view source

Declarations
#

2 declarations

format_bytes
#

bytes.ts view source

(n: number): string import {format_bytes} from '@fuzdev/fuz_util/bytes.js';

Formats a byte count as a human-readable string.

n

type number

returns

string

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

to_bytes
#

bytes.ts view source

(data: string | Uint8Array<ArrayBufferLike> | BufferSource): Uint8Array<ArrayBufferLike> import {to_bytes} from '@fuzdev/fuz_util/bytes.js';

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

data

type string | Uint8Array<ArrayBufferLike> | BufferSource

returns

Uint8Array<ArrayBufferLike>

Uint8Array view of the data

Imported by
#