shuffrand
Version:
Cryptographically secure randomness and shuffling — with soul.
18 lines (16 loc) • 1.22 kB
TypeScript
import { RandomParams } from './src.types.js';
/**
* Generates a cryptographically secure random number within a specified range.
*
* @param {RandomParams} [rawParams={}] - The raw parameters for random number generation.
* @param {number} [rawParams.lowerBound=0] - The lower bound (inclusive) of the random number.
* @param {number} [rawParams.upperBound=2] - The upper bound (exclusive for doubles, inclusive for integers) of the random number.
* @param {'integer'|'double'} [rawParams.typeOfNum='integer'] - The type of number to generate ('integer' (default) or 'double').
* @param {'none'|'lower bound'|'upper bound'|'both'} [rawParams.exclusion='none'] - Specifies which bounds to exclude.
* @param {number} [rawParams.maxFracDigits=3] - The maximum number of fractional digits for 'double' type numbers.
* If specified, the generated double will be rounded to this many decimal places.
* Must be a non-negative integer between 0 and 15. Defaults to `3`.
* @returns {number} - A cryptographically secure random number.
* @throws {TypeError} - If input parameters do not conform to the schema or if an invalid range is provided.
*/
export declare function cryptoRandom(rawParams?: RandomParams): number;