• Rounds a number to a multiple.

    Example

    Round to multiple of 5

    const roundTo5 = roundToMultiple(5);

    console.log(roundTo5(4)); // 5

    console.log(roundTo5(-3)); // -5

    Example

    Round to -3, 2, 7, ...

    const roundTo5Plus2 = roundToMultiple(5, 2);

    console.log(roundTo5Plus2(0)); // 2

    console.log(roundTo5Plus2(8)); // 7

    console.log(roundTo5Plus2(-5)); // -3

    Returns

    the rounded number

    Parameters

    • multiple: number

      the multiple to round to

    • shift: number = 0

      optional shift to apply

    Returns ((num: number) => number)

      • (num: number): number
      • Parameters

        • num: number

        Returns number

Generated using TypeDoc