unique-integer

1.0.0 • Public • Published

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)

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

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

Package Sidebar

Install

npm i unique-integer

Weekly Downloads

17

Version

1.0.0

License

ISC

Unpacked Size

7.55 kB

Total Files

5

Last publish

Collaborators

  • trolleymusic