| 2 | import { PRNG } from "./types.js"; |
| 3 | |
| 4 | export function randomChar(prng: PRNG): string { |
| 5 | // Currently PRNGs generate fractions from 0 to _less than_ 1, so no "%" is necessary. |
| 6 | // However, just in case a future PRNG can generate 1, |
| 7 | // we are applying "% ENCODING LEN" to wrap back to the first character |
| 8 | const randomPosition = Math.floor(prng() * ENCODING_LEN) % ENCODING_LEN; |
| 9 | return ENCODING.charAt(randomPosition); |
| 10 | } |
| 11 | |
| 12 | export function replaceCharAt(str: string, index: number, char: string): string { |
| 13 | if (index > str.length - 1) { |