Functions
- uniqueInteger() ⇒
number
Generate a unique integer - default exported function
import uniqueInteger from 'unique-integer'
const id = uniqueInteger()
- avoidClashes(options) ⇒
number
Generate a unique integer avoiding a particular range
import assert from 'assert' import { avoidClashes } from 'unique-integer'
const ceiling = 1000 const floor = 0 const id = avoidClashes({ ceiling, floor }) assert(id > ceiling) assert(id < floor)
number
uniqueInteger() ⇒ Generate a unique integer - default exported function
const id =
Kind: global function
Returns: number
- A unique integer
number
avoidClashes(options) ⇒ Generate a unique integer avoiding a particular range
const ceiling = 1000const floor = 0const id =
Kind: global function
Returns: number
- A unique integer
Param | Type | Description |
---|---|---|
options | Object |
|
options.ceiling | number |
lower bound of the range to avoid |
options.floor | number |
upper bound of the range to avoid |