@gapit/format-si
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

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" }

Dependencies (0)

    Dev Dependencies (10)

    Package Sidebar

    Install

    npm i @gapit/format-si

    Weekly Downloads

    7

    Version

    0.0.1

    License

    MIT

    Unpacked Size

    15.4 kB

    Total Files

    9

    Last publish

    Collaborators

    • ulberg
    • sverret
    • flesa
    • mjos
    • oklk
    • zuperzee