parseSize
parseSize(
size):number
Defined in: packages/storage/src/schema.ts:31
Parse a human-readable size string into bytes.
Supports b, kb, mb, and gb units (case-insensitive). Decimal values
are supported and the result is rounded to the nearest byte.
Parameters
Section titled “Parameters”string
Size string (e.g. "10mb", "1.5kb", "500b", "1gb").
Returns
Section titled “Returns”number
The size in bytes.
Throws
Section titled “Throws”If the format is invalid.
Example
Section titled “Example”import { parseSize } from "@cfast/storage";
parseSize("2mb"); // 2097152parseSize("1.5kb"); // 1536parseSize("500b"); // 500