Mike Rockétt Software Developer + Designer, Megafreight
← Open Source

Human Bytes

beta #v



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

Based on work done by Sindre.


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

Installation Instructions

Package is not available on vpkg or vpm yet