shuffrand
Version:
Cryptographically secure randomness and shuffling — with soul.
77 lines (76 loc) • 2.67 kB
TypeScript
/**
* Parameters for the cryptoRandom function.
*/
export interface RandomParams {
lowerBound?: number;
upperBound?: number;
typeOfNum?: 'integer' | 'double';
exclusion?: 'none' | 'lower bound' | 'upper bound' | 'both';
maxFracDigits?: number;
}
/**
* ArkType schema for validating RandomParams.
*/
export declare const randomParamsSchema: import('arktype/internal/methods/object.ts').ObjectType<{
lowerBound?: number | undefined;
upperBound?: number | undefined;
typeOfNum?: "integer" | "double" | undefined;
exclusion?: "none" | "lower bound" | "upper bound" | "both" | undefined;
maxFracDigits?: number | undefined;
}, {}>;
/**
* Parameters for the cryptoShuffle function.
*/
export interface ShuffleParams<T> {
arr?: T[];
isDestructive?: boolean;
preventIdentical?: boolean;
/**
* The starting index of the subarray to shuffle (inclusive).
* Defaults to 0, shuffling from the beginning of the array.
* Must be a non-negative integer within the array bounds.
* If greater than or equal to `endIndex`, no shuffling occurs on the subarray.
* @since 1.6.0
*/
startIndex?: number;
/**
* The ending index of the subarray to shuffle (exclusive).
* Defaults to the array's length, shuffling to the end of the array.
* Must be a non-negative integer within the array bounds (0 to arr.length).
* If less than or equal to `startIndex`, no shuffling occurs on the subarray.
* @since 1.6.0
*/
endIndex?: number;
}
/**
* ArkType schema for validating ShuffleParams.
* Note: startIndex and endIndex validation is handled by custom logic in the function
* due to ArkType v2.1.20 issues with optional constrained fields.
*/
export declare const shuffleParamsSchema: import('arktype/internal/methods/object.ts').ObjectType<{
arr?: unknown[] | undefined;
isDestructive?: boolean | undefined;
preventIdentical?: boolean | undefined;
startIndex?: unknown;
endIndex?: unknown;
}, {}>;
/**
* Parameters for the cryptoString function.
*/
export interface CryptoStringParams {
length?: number;
characterSet?: 'alphanumeric' | 'numeric' | 'alpha' | 'hex' | 'uppercase' | 'lowercase' | string;
/**
* If true, ensures no character appears more than once in the result.
* Defaults to `false`.
*/
noRepeat?: boolean;
}
/**
* ArkType schema for validating CryptoStringParams.
*/
export declare const cryptoStringParamsSchema: import('arktype/internal/methods/object.ts').ObjectType<{
length?: number | undefined;
characterSet?: string | undefined;
noRepeat?: boolean | undefined;
}, {}>;