@huth/random
v6.0.2
Published
Simple utility wrapper for generating randomness.
Readme
Random
This is a simple wrapper that provides utilities for dealing with randomness. This library generally uses Math.random as its random number generator.
npm install @huth/random
Default export contains all available methods:
import random from "@huth/random"
random.pick("Rose", "Blanche", "Dorothy", "Sophia") // "Dorothy" API
The API includes the following methods for producing usefull random data:
float(min: number, max: number): numberinclusive random floatinteger(min: number, max: number): numberinclusive random integerboolean(likelihood = .5): booleanboolean wherelikelihoodis a number in the range [0, 1] increasing the chance oftruepick<T>(...args: T[]): Treturns a random element from the arguments providedid(): stringgenerates an id viacrypto.getRandomValues()
