Wondering what’s next for npm?Check out our public roadmap! »

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

    1.1.0 • Public • Published

    Round intervals Travis CI Build Status

    Round a number to the closest interval.

    NPM Badge

    Install

    npm install round-intervals

    Usage

    const roundIntervals = require("round-intervals")
     
    roundIntervals(1, 5)
    //=> 0
     
    roundIntervals(4, 5)
    //=> 5
     
    roundIntervals(8, 5)
    //=> 10
     
    roundIntervals.up(1, 5)
    //=> 5
     
    roundIntervals.up(4, 5)
    //=> 5
     
    roundIntervals.down(1, 5)
    //=> 0
     
    roundIntervals.down(4, 5)
    //=> 0

    API

    roundIntervals(number, intervals)

    Round number to the nearest interval.

    roundIntervals.up(number, intervals)

    Round number up to the nearest interval.

    roundIntervals.down(number, intervals)

    Round number down to the nearest interval.

    number

    Type: number

    The number to round.

    intervals

    Type: number

    The intervals to round to.

    Install

    npm i round-intervals

    DownloadsWeekly Downloads

    4

    Version

    1.1.0

    License

    MIT

    Unpacked Size

    4.52 kB

    Total Files

    6

    Last publish

    Collaborators

    • avatar