Parse string
reverse
https://github.com/saket/byte-size/blob/3abe56bb60fc91e31c4443b7c4c381e4fa7773b7/library/src/commonMain/kotlin/me/saket/bytesize/BinaryByteSize.kt#L79-L91
I'm sorry, but byte-size is focused on doing one thing well: representing and formatting byte sizes. Adding parsing would expand the scope significantly and invite many edge case requests.
What's your use case?
in configurations, something like:
avatars:
size-limit: 1MB
we can refer to Duration.kt.
https://github.com/JetBrains/kotlin/blob/dd0262b0a119245bb666a48919211cd3da77f45c/libraries/stdlib/src/kotlin/time/Duration.kt#L1023-L1246
Your example would fail to parse, though. And would yield 1,000,000 bytes instead of 1,048,576 bytes which I'm not sure this person would expect or not.
Parsing is a delicate thing. Some people want it to be strict, others lenient (such as allowing no space), and others still want it to parse to what they meant not what they necessarily said (such as in the case of MB vs. MiB).