Random

This Random package is a simple and flexible utility for generating random values in JavaScript and TypeScript. You can generate numeric, string and boolean values with full control over the generation using parameters.

Usage

import {
  randomBoolean,
  randomBooleanArray,
  randomUUID,
  randomUUIDArray,
} from "@n-eeraj/random"

Exported Functions

randomBoolean() Generates a random boolean value.

Example Usage:

randomBoolean()
// Returns a random boolean

randomBooleanArray(length) Generates an of random boolean values.

Example Usage:

randomBooleanArray(5)
// Returns an array of 5 random booleans

randomUUID() Generates a random UUID using crypto.randomUUID().

Example Usage:

randomUUID()
// Returns a random UUID

randomUUIDArray(length) Generates an of random UUID using crypto.randomUUID().

Example Usage:

randomUUIDArray(5)
// Returns an array of 5 random UUIDs

Read more about crypto.randomUUID().