I needed a fast way to format byte counts into KB, MB, or GB and parse those strings back into integers without pulling in a heavy npm package.
This TypeScript module relies entirely on the standard library. There are no external dependencies to install or backend services to configure.
humanbytes.ts
Check the test file located next to the implementation to see how the formatting and parsing logic actually behaves in practice.