We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ByteSize
I think helpers to format pairs of 2 ByteSize in progress-like scenarios might come in handy:
(Sorry I like F#)
open ByteSizeLib [<RequireQualifiedAccess>] module Tuple2 = let map f (a, b) = f a, f b [<RequireQualifiedAccess>] module ByteSize = let ofBytes bytes = ByteSize(bytes=bytes) let ofBits bits = ByteSize(bits=bits) let getDecValueOfSymbol decSymbol (value: ByteSize) = match decSymbol with | ByteSize.PetaByteSymbol -> value.PetaBytes | ByteSize.TeraByteSymbol -> value.TeraBytes | ByteSize.GigaByteSymbol -> value.GigaBytes | ByteSize.MegaByteSymbol -> value.MegaBytes | ByteSize.KiloByteSymbol -> value.KiloBytes | ByteSize.ByteSymbol -> value.Bytes | _ -> failwith $"{decSymbol} is not supported a decimal symbol." let getBinValueOfSymbol binSymbol (value: ByteSize) = match binSymbol with | ByteSize.PebiByteSymbol -> value.PebiBytes | ByteSize.TebiByteSymbol -> value.TebiBytes | ByteSize.GibiByteSymbol -> value.GibiBytes | ByteSize.MebiByteSymbol -> value.MebiBytes | ByteSize.KibiByteSymbol -> value.KibiBytes | ByteSize.BitSymbol -> double value.Bits | _ -> failwith $"{binSymbol} is not supported a binary symbol." let toDecString (value: ByteSize) = value.ToString(value.LargestWholeNumberDecimalSymbol) let toBinString (value: ByteSize) = value.ToString(value.LargestWholeNumberBinarySymbol) let formatDecPair separator (value, maxValue: ByteSize) = (getDecValueOfSymbol maxValue.LargestWholeNumberDecimalSymbol value, separator, toDecString maxValue) |||> sprintf "%g%s%s" let formatBinPair separator (value, maxValue: ByteSize) = (getBinValueOfSymbol maxValue.LargestWholeNumberBinarySymbol value, separator, toBinString maxValue) |||> sprintf "%g%s%s" [<EntryPoint>] let main _ = [ 230. , 5000000. 512 , 4500123. 63120. , 666400000430. 63120. , 23400000435000. 99312312120. , 12312323406706000000. ] |> List.map (Tuple2.map ByteSize.ofBytes) |> List.map (ByteSize.formatBinPair @"/") |> List.iter (printfn "%s") [<EntryPoint>] let main _ = [ 230. , 5000000. 512 , 4500123. 63120. , 666400000430. 63120. , 23400000435000. 99312312120. , 12312323406706000000. ] |> List.map (Tuple2.map ByteSize.ofBytes) |> List.map (ByteSize.formatBinaryProgress @"/") |> List.iter (printfn "%s")
Output:
0.000219345/4.77 MiB 0.000488281/4.29 MiB 5.87851e-05/620.63 GiB 5.74073e-08/21.28 TiB 8.82071e-05/10935.54 PiB
Found it quite convenient
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I think helpers to format pairs of 2
ByteSize
in progress-like scenarios might come in handy:(Sorry I like F#)
Output:
Found it quite convenient
The text was updated successfully, but these errors were encountered: