0.5.1 • Published 2 years ago

@batou.dev/bytes v0.5.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Bytes

Bytes is a library for working with byte sizes in JavaScript with native Intl support.

Bytes.fromBytes(1024).toString() // = 1 KiB

Bytes.fromString("1,234.56 GiB", {locale: "en"}).toDecimal({locale: "fr"}) // = 1,33 TB

Bytes.fromString("1234.56kB").toFormat("%.3m") // = 1.235 MB

Bytes.fromString("1234.56 GiB").valueOf() // = 1325598706237

Bytes.fromString("123.45 MB").add("1.23 MiB").toBinary() // = 118.96 MiB

Bytes.fromString("12.345 MiB").as("kilobytes") // = 12944.67072

Install

To get started using Bytes, add the dependency via npm:

npm install @batou.dev/bytes

ES6:

import {Bytes} from "@batou.dev/bytes";

Node.js:

const {Bytes} = require("@batou.dev/bytes");

Note

⚠️ IMPORTANT: this library is at an early stage, thus breaking changes might still occur as its development evolves.

Links

License

This code is licensed and distributed under the term of the MIT license.

0.5.1

2 years ago

0.5.0

2 years ago

0.3.0

3 years ago

0.4.0

3 years ago

0.2.0

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago