0.0.1 • Published 4 years ago

@gapit/format-si v0.0.1

Weekly downloads
8
License
MIT
Repository
github
Last release
4 years ago

Format SI

Format a number into SI metric prefixed value.

Usage

There are three different functions that converts a value into SI metric prefixed value.

formatSI()

Converts a number into the metric prefixed value.

Example:

formatSI(10000, "W"); // Returns { value: 10, unit: "kW" }

formatFixedSI()

Uses formatSI() to convert the number, but it adds .toFixed(fractionDigits) to the value.

Example:

formatFixedSI(10000 "W", 3,); // Returns { value: "10.000", unit: "kW" }

formatPrecisionSI()

Uses formatSI() to convert the number, but it adds .toPrecision(precision) to the value.

Example:

formatPrecisionSI(10000 "W", 3,); // Returns { value: "10.0", unit: "kW" }