1.0.1 • Published 2 years ago
round-to-step v1.0.1
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
How to use
npm install round-to-step
import { roundToStep } from 'round-to-step'