increlation

2.0.1 • Public • Published

Increlation

An incremenentor that is limited to a minimum and maximum value, but allows reusing a value once resolved.

Install

npm install --save increlation

Usage

Sync

increlation.sync (minimum, maximum)

const increlation = require('increlation');

const incrementor = increlation.sync(1, 10);

incrementor.next() // === { done: false, value: 1 }
incrementor.next() // === { done: false, value: 2 }
///...
incrementor.next() // === { done: false, value: 10 }
incrementor.release(5)
incrementor.next() // === { done: false, value: 5 }
incrementor.next() // === { done: true, value: null }

Async

increlation.async (minimum, maximum, timeout = Infinity)

const increlation = require('increlation');

const incrementor = increlation.async(1, 10, 1000);

await incrementor.next() // === { done: false, value: 1 }
await incrementor.next() // === { done: false, value: 2 }
///...
await incrementor.next() // === { done: false, value: 10 }
incrementor.next().then(result => {
  result // === { done: false, value: 5 }
})
incrementor.release(5)

Dependencies (0)

    Dev Dependencies (2)

    Package Sidebar

    Install

    npm i increlation

    Weekly Downloads

    9

    Version

    2.0.1

    License

    MIT

    Unpacked Size

    7.53 kB

    Total Files

    10

    Last publish

    Collaborators

    • markwylde