Skip to content

D10f/digital

Repository files navigation

A parser that converts strings of digital data storage units into byte representation. Currently supported magnitudes are: bytes, kilobytes, megabytes, gigabytes, terabytes and petabytes.

Usage:

Import it into your project using CommonJS or ESM modules:

import parse from '@d10f/digital';
// const parse = require('@d10f/digital');

parse('12.5 Gigabytes'); // 12500000000

It also supports binary system for better precision:

parse('12.5 Gibibytes'); // 1342177800

For convenience you can provide the shorthand for each unit of measurement (case insensitive):

parse('12.5 Gb');
parse('12.5 Gib');

TODO:

  • Support for BigInt returns exabytes, zettabytes and yottabytes.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published