# number-steps

> ```js const {step} = require("./number-steps");

Latest version **1.0.2** (published 2019-08-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install number-steps
pnpm add number-steps
yarn add number-steps
bun add number-steps
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2019-08-10 |
| First published | 2019-08-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Matthias Kainer |
| Maintainers | matkainer |

## Links

- npm: https://www.npmjs.com/package/number-steps
- npm.io page: https://npm.io/package/number-steps

## Recent versions

- 1.0.2 (latest) — 2019-08-10
- 1.0.1 — 2019-08-10
- 1.0.0 — 2019-08-10

## README

# number-steps

```js
const {step} = require("./number-steps");

describe("number-steps", () => {
    describe("Bugs", () => {
        it("should handle the -1 case correctly", () => {
            expect(step({size : 1, snap: true}).down(-1)).toBe(-2)
        });
        it("should handle the 1 case correctly", () => {
            expect(step({size : 1, snap: true}).up(1)).toBe(2)
        });
    })

    describe("Happy Case", () => {
        it("should resolve non-snapped steps correctly", () => {
            expect(step({size : 50}).up(23)).toBe(73)
            expect(step({size : 50}).up(-23)).toBe(27)
            expect(step({size : 50}).down(23)).toBe(-27)
            expect(step({size : 50}).down(-23)).toBe(-73)
        })

        it.each`value | expected
        ${-23} | ${0}
        ${-100}| ${-50}
        ${-115}| ${-100}
        ${-145}| ${-100}
        ${-150}| ${-100}
        ${-155}| ${-150}
        ${-200}| ${-150}
        ${-250}| ${-200}
        ${0}| ${50}
        ${23}| ${50}
        ${115}| ${150}
        ${145}| ${150}
        ${150}| ${200}
        `("should resolve the snapped up steps for $value and step size 50 correctly", ({value, expected}) => {
            expect(step({size : 50, snap: true}).up(value)).toBe(expected)
        })

        it.each`value | expected
        ${-23} | ${0}
        ${-115}| ${-92}
        ${-145}| ${-138}
        ${-155}| ${-138}
        ${0}| ${23}
        ${23}| ${46}
        ${116}| ${138}
        ${145}| ${161}
        `("should resolve the snapped up steps for $value and step size 23 correctly", ({value, expected}) => {
            expect(step({size : 23, snap: true}).up(value)).toBe(expected)
        })

        it.each`value | expected
        ${-23} | ${-50}
        ${-115}| ${-150}
        ${-145}| ${-150}
        ${-150}| ${-200}
        ${-155}| ${-200}
        ${0}| ${-50}
        ${23}| ${0}
        ${115}| ${100}
        ${145}| ${100}
        ${150}| ${100}
        ${155}| ${150}
        `("should resolve the snapped down steps for $value and step size 50 correctly", ({value, expected}) => {
            expect(step({size : 50, snap: true}).down(value)).toBe(expected)
        })
    })
})
```

---
_Source: https://npm.io/package/number-steps · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
