Mike Rockétt Systems Developer & Designer @ Megafreight
← Open Source

Human Bytes

Home/Repo Link

https://github.com/mikerockett/human_bytes

Readme

A package for V that converts bytes into human-friendly strings.

Based on work done by Sindre.

Usage:

import human_bytes { convert, convert_opt }

// Normal conversions
convert(10) // 10 B
convert(1001) // 1 kB

// Conversions with options
convert_opt(1001, signed: true) // +1 kB
convert_opt(1001, bits: true) // 1 kbit
convert_opt(1e16, binary: true) // 8.88 PiB
convert_opt(1025, bits: true, binary: true, signed: true) // +1 kibit