npm

Need private packages and team management tools?Check out npm Orgs. »

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

install

npm i unique-integer

Downloadsweekly downloads

21

version

1.0.0

license

ISC

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability