File size string to number parser?
Hi everyone, I'm looking for a library that can parse a string such as "12.3Mb" or any other unit of measurement of information (b, kb, mb, gb, etc), and returns me the integer amount in bytes for that string. Does anyone know of something like that?
6 Replies
Here's your lib!
Might have to finesse it a bit, but it's functional!
Hey, thanks š
I'm actually looking for an actual npm package that's available and that I can install
It'sā¦5 lines of code (plus the multiplier object). Make a file and export
giveMeBytes
lol. Why the need for an NPM package?Yeah I know, but I ended up writing my own code that accounts for both decimal and binary systems (kb and kib), and has checks to esnure the string is valid and whatnot. So I was wondering if there's another library I can compare it to
Gotcha gotcha
Not like I don't appreciate the help btw š