Skip to content

Generate random numbers that are consecutively unique

License

Notifications You must be signed in to change notification settings

elonehoo/only-random

Repository files navigation

only-random

NPM version

Generate random numbers that are consecutively unique

Useful for things like slideshows where you don't want to have the same slide twice in a row.

install

# npm
npm install --save @elonehoo/only-random
# yarn
yarn add --save @elonehoo/only-random
# pnpm
pnpm install --save @elonehoo/only-random

usage

import onlyRandom from '@elonehoo/only-random'

const random = onlyRandom(1, 10)

console.log(random(), random(), random())

API

onlyRandom(minimum:number, maximum:number)

Returns a function, that when called, will return a random number that is never the same as the previous.

About

Generate random numbers that are consecutively unique

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published