Units
Function | Description | Meta |
---|---|---|
units.parse |
Converts strings like "10G", "5K", "4M", "1500m", and the like into a number. This number can be a non-integer, such as 1.5, 0.22, etc. Scientific notation is supported, allowing values such as "1e-3K" (1) or "2.5e6M" (2.5 million M). Supports standard metric decimal and binary SI units (e.g., K, Ki, M, Mi, G, Gi, etc.) where m, K, M, G, T, P, and E are treated as decimal units and Ki, Mi, Gi, Ti, Pi, and Ei are treated as binary units. Note that 'm' and 'M' are case-sensitive to allow distinguishing between "milli" and "mega" units respectively. Other units are case-insensitive. Arguments: Returns:x (string)the unit to parse y (number)the parsed number | v0.41.0 SDK-dependent |
units.parse_bytes |
Converts strings like "10GB", "5K", "4mb", or "1e6KB" into an integer number of bytes. Supports standard byte units (e.g., KB, KiB, etc.) where KB, MB, GB, and TB are treated as decimal units, and KiB, MiB, GiB, and TiB are treated as binary units. Scientific notation is supported, enabling values like "1.5e3MB" (1500MB) or "2e6GiB" (2 million GiB). The bytes symbol (b/B) in the unit is optional; omitting it will yield the same result (e.g., "Mi" and "MiB" are equivalent). Arguments: Returns:x (string)the byte unit to parse y (number)the parsed number | SDK-dependent |