@grandom/shuffle
Version:
A configurable, flexible, seedable, and overall great random shuffler.
48 lines (47 loc) • 1.7 kB
TypeScript
import { RandomGenerator, RandomEngine } from '@grandom/core';
export interface ShuffleStringOptions {
/**
* Filters the input string by character.
*
* @param character The specific character to filter from the input string.
* @returns Whether to keep the specific character in the shuffle pool.
*/
filter?: (character: string) => boolean;
/**
* Exclude one or multiple characters from the input string.
*/
exclude?: string | RegExp | Array<string | RegExp>;
}
export default class RandomStringShuffle extends RandomGenerator {
constructor(engine: RandomEngine);
canBeParsed(arg1: any): boolean;
parse(arg1: any, arg2: any, arg3: any): any;
/**
* Shuffles (mixes) the input string and returns it.
*
* @param string The string to shuffle.
*/
shuffle(string: string): string;
/**
* Shuffles (mixes) the input string and returns it.
*
* @param string The string to shuffle.
* @param count The count (length) of the returned string.
*/
shuffle(string: string, count: number): string;
/**
* Shuffles (mixes) the input string and returns it.
*
* @param string The string to shuffle.
* @param options Shuffle options (filtering and fallback).
*/
shuffle(string: string, options: ShuffleStringOptions): string;
/**
* Shuffles (mixes) the input string and returns it.
*
* @param string The string to shuffle.
* @param count The count (length) of the returned string.
* @param options Shuffle options (filtering and fallback).
*/
shuffle(string: string, count: number, options: ShuffleStringOptions): string;
}