round-to-step
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

roundToStep

Round a number to a step. Accepts an interval and optional offset.

const rounded = roundToStep(45, { offset: 20, interval: 10 })
console.log(rounded) // 50
const rounded = roundToStep(45, { offset: 20, interval: 10, direction: 'down' })
console.log(rounded) // 40

Options

Option Default Description
offset 0 The start of the series
interval 1 The distance between the numbers
direction commercial up, down or commercial

How to use

npm install round-to-step
import { roundToStep } from 'round-to-step'

/round-to-step/

    Package Sidebar

    Install

    npm i round-to-step

    Weekly Downloads

    2

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    9.62 kB

    Total Files

    11

    Last publish

    Collaborators

    • simon-leber