• Convert miles, feet and inches to metric units and kilometers, meters and centimeters to imperial units as appropriate.

    Parameters

    • value: number

      A numeric value representing the length of the distance

    • type: "mi" | "km" | "ft" | "in" | "m" | "cm"

      The distance unit

    Returns [range: number, unit: "mi" | "km" | "ft" | "in" | "m" | "cm"]

    • The resulting value and unit
    pf1.utils.swapDistance(30, "ft"); // => [9, "m"]
    pf1.utils.swapDistance(9, "m"); // => [30, "ft"]
    pf1.utils.swapDistance(1, "in"); // => [2.5, "cm"]
    • On invalid parameters.