1.0.0 • Published 5 years ago

unique-integer v1.0.0

Weekly downloads
33
License
ISC
Repository
github
Last release
5 years ago

Functions

const id = uniqueInteger()

const ceiling = 1000 const floor = 0 const id = avoidClashes({ ceiling, floor }) assert(id > ceiling) assert(id < floor)

uniqueInteger() ⇒ number

Generate a unique integer - default exported function

import uniqueInteger from 'unique-integer'

const id = uniqueInteger()

Kind: global function
Returns: number - A unique integer

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)

Kind: global function
Returns: number - A unique integer

ParamTypeDescription
optionsObject
options.ceilingnumberlower bound of the range to avoid
options.floornumberupper bound of the range to avoid
1.0.0

5 years ago