Documents for @litert/utils-number
    Preparing search index...

    Type Parameters

    • T extends string | number
    Index

    Constructors

    Methods

    • Convert a value from one unit to another.

      Parameters

      • value: number

        The value to be converted.

      • from: T

        The unit that the value currently is in.

      • to: T

        The unit that the value should be converted to.

      Returns number

      The converted value, in the target unit.

      `convert(1.23, "m", "cm") returns 123`.
      
    • This method helps create a sequence of units, multiplied by the same factor.

      So each unit is factor times of the previous unit, while the first unit is factor times of the base unit.

      Type Parameters

      • T extends string | number

      Parameters

      • units: T[]

        The list of unit names (or symbols) to be converted.

      • factor: number

        The factor for the conversion.

      Returns IUnit<T>[]

      The list of unit objects.

      `makeUnitsByFactor(["kb", "mb", "gb", "tb"], 1024)` where `byte` is the base unit