Is there a good library that wraps up memory sizes...
# general-advice
r
Is there a good library that wraps up memory sizes in a class, like
Duration
does for time durations? I'm imagining:
Copy code
val maxSize: MemorySize = 2.gigabytes
assert(maxSize.bytes == 2_147_483_648L)
assert(maxSize.toString() == "2GB")
or something like that
k
There was also this discussion recently.
s
I thought of this https://github.com/saket/file-size when I saw your question, mind you I have never tried it, but you can give it a look
r
Thanks very much all for the pointers, I'll have a look at them
k
It seems the biggest difference between them is that some (like saket/file-size) use 1000 bytes per KB, some use 1024, and some give you the option to choose.