0.2.21 • Published 1 year ago

@trenskow/units v0.2.21

Weekly downloads
1
License
BSD-2-Clause
Repository
github
Last release
1 year ago

@trenskow/units

Small library for parsing units.

Usage

const
	{ bytes, duration } = require('@trenskow/units/');
bytes.kib('1024b');
/* returns: 1 */

bytes.b('1kb');
/* returns: 1000 */

bytes('4kib'); /* defaults to bytes as return unit */
/* returns 4096 */
duration.hours('2d');
/* returns: 48 */

duration.ms('2s');
/* return: 2000 */

duration('2h'); /* defaults to seconds as return unit */
/* returns 7200 */

Supported units

Bytes

B, EB, Ebyte, Ebytes, EiB, Eibyte, Eibytes, GB, Gbyte, Gbytes, GiB, Gibyte, Gibytes, KiB, Kibyte, Kibytes, MB, Mbyte, Mbytes, MiB, Mibyte, Mibytes, PB, Pbyte, Pbytes, PiB, Pibyte, Pibytes, TB, Tbyte, Tbytes, TiB, Tibyte, Tibytes, YB, Ybyte, Ybytes, YiB, Yibyte, Yibytes, ZB, Zbyte, Zbytes, ZiB, Zibyte, Zibytes, byte, bytes, daB, dabyte, dabytes, decaB, decabyte, decabytes, exaB, exabyte, exabytes, exbiB, exbibyte, exbibytes, gibiB, gibibyte, gibibytes, gigaB, gigabyte, gigabytes, hB, hbyte, hbytes, hectoB, hectobyte, hectobytes, kB, kbyte, kbytes, kibiB, kibibyte, kibibytes, kiloB, kilobyte, kilobytes, megaB, megabyte, megabytes, mibiB, mibibyte, mibibytes, pebiB, pebibyte, pebibytes, petaB, petabyte, petabytes, tebiB, tebibyte, tebibytes, teraB, terabyte, terabytes, yobiB, yobibyte, yobibytes, yottaB, yottabyte, yottabytes, zebiB, zebibyte, zebibytes, zettaB, zettabyte and zettabytes.

Durations

as, asecond, aseconds, attos, attosecond, attoseconds, centis, centisecond, centiseconds, cs, csecond, cseconds, d, day, days, decis, decisecond, deciseconds, ds, dsecond, dseconds, femtos, femtosecond, femtoseconds, fs, fsecond, fseconds, h, hour, hours, m, micros, microsecond, microseconds, millis, millisecond, milliseconds, minute, minutes, ms, msecond, mseconds, nanos, nanosecond, nanoseconds, ns, nsecond, nseconds, picos, picosecond, picoseconds, ps, psecond, pseconds, s, second, seconds, w, week, weeks, y, year, years, yoctos, yoctosecond, yoctoseconds, ys, ysecond, yseconds, zeptos, zeptosecond, zeptoseconds, zs, zsecond, zseconds, μs, μsecond, μseconds

LICENSE

2-Clause BSD License (SEE LICENSE)

0.2.21

1 year ago

0.2.20

1 year ago

0.2.19

1 year ago

0.2.18

1 year ago

0.2.17

1 year ago

0.2.16

1 year ago

0.2.15

1 year ago

0.2.14

1 year ago

0.2.13

1 year ago

0.2.12

1 year ago

0.2.11

1 year ago

0.2.10

1 year ago

0.2.7

1 year ago

0.2.6

1 year ago

0.2.9

1 year ago

0.2.8

1 year ago

0.2.5

2 years ago

0.2.4

2 years ago

0.2.3

2 years ago

0.2.2

2 years ago

0.2.1

2 years ago

0.1.10

2 years ago

0.1.11

2 years ago

0.2.0

2 years ago

0.1.8

3 years ago

0.1.9

3 years ago

0.1.7

3 years ago

0.1.6

4 years ago

0.1.4

4 years ago

0.1.5

4 years ago

0.1.3

4 years ago

0.1.2

5 years ago

0.1.1

6 years ago

0.1.0

6 years ago