# decrement

> Auto decrement value at preset rate.

Latest version **1.25.0** (published 2025-02-25) · ISC license · 0 weekly downloads

## Install

```sh
npm install decrement
pnpm add decrement
yarn add decrement
bun add decrement
```

## Health

**Score 35/100 (D)** — status: stable.

Positive: no vulnerabilities.

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

Negative: stale.

## Facts

| | |
|---|---|
| Version | 1.25.0 |
| Published | 2025-02-25 |
| First published | 2017-05-17 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 427.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | fantasyui.com |
| Maintainers | fantasyui.com |

## Links

- npm: https://www.npmjs.com/package/decrement
- Repository: https://github.com/fantasyui-com/decrement
- Homepage: https://github.com/fantasyui-com/decrement#readme
- Issues: https://github.com/fantasyui-com/decrement/issues
- npm.io page: https://npm.io/package/decrement

## Dependencies (5)

- [oneof](https://npm.io/package/oneof.md) ^1.1.0
- [lodash](https://npm.io/package/lodash.md) ^4.17.15
- [moment](https://npm.io/package/moment.md) ^2.24.0
- [shelljs](https://npm.io/package/shelljs.md) ^0.8.3
- [sprintf-js](https://npm.io/package/sprintf-js.md) ^1.1.2

## Recent versions

- 1.25.0 (latest) — 2025-02-25
- 1.24.0 — 2024-12-14
- 1.23.0 — 2024-08-22
- 1.22.0 — 2024-08-18
- 1.21.0 — 2024-06-01
- 1.20.0 — 2024-04-23
- 1.19.0 — 2024-02-29
- 1.18.0 — 2024-01-06
- 1.17.0 — 2023-10-28
- 1.16.0 — 2023-09-08
- 1.15.0 — 2022-10-26
- 1.14.0 — 2022-10-14
- 1.13.0 — 2022-04-27
- 1.12.0 — 2022-04-10
- 1.11.0 — 2022-02-10
- … 11 more at https://npm.io/package/decrement/versions

## README

# decrement
Decrement random value in array. Image below demonstrates random decrements in rgb(255,255,255) structure.

![Distribution Example](screenshot.png)

(See sample output [test.html](test.html) for full dataset)


    // install decrement
    npm i -S decrement

    // load
    const decrement = require("decrement");

    // cap at range of 0..255
    const control = decrement({min:0, max:255});

    // helper rate change
    const rnd = function (min, max) {
      min = Math.ceil(min);
      max = Math.floor(max);
      return Math.floor(Math.random() * (max - min + 1)) + min;
    }

    // insert objects
    control.insert ( { kind: 'red'   , value: 255 } ) ;
    control.insert ( { kind: 'green' , value: 255 } ) ;
    control.insert ( { kind: 'blue'  , value: 255 } ) ;

    // while above 0
    while( control.total() > 0){

      // find blue and change by a random value in range -2..1
      control.change({kind: 'blue'},  rnd(-2,1));

      // find green and change by a random value in range -2..1
      control.change({kind: 'green'}, rnd(-2,1));

      // find red and change by a random value in range -2..1
      control.change({kind: 'red'},   rnd(-2,1));

      // print some html
      console.log( '<div style="background: rgb(' + control.data().map(i=>i.value).join() + '); height:1px;"></div>' );
    }

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