(digit = 8)
| 128 | }); |
| 129 | |
| 130 | export const randomId = (digit = 8) => { |
| 131 | // 1. Grab a cryptographically-secure 32-bit random value |
| 132 | // Use crypto for stronger randomness |
| 133 | const randomBytes = crypto.getRandomValues(new Uint32Array(1)); |
| 134 | const raw = randomBytes[0]; // 0 … 4,294,967,295 |
| 135 | |
| 136 | // Calculate the min and max for the given digit length |
| 137 | const min = Math.pow(10, digit - 1); // e.g., digit=3 → 100 |
| 138 | const max = Math.pow(10, digit) - 1; // e.g., digit=3 → 999 |
| 139 | const range = max - min + 1; |
| 140 | |
| 141 | // Collapse random value into the range and shift |
| 142 | return min + (raw % range); |
| 143 | }; |
| 144 | //function for create list of year for date widget |
| 145 | export const range = (start, end, step) => { |
| 146 | const range = []; |
no outgoing calls
no test coverage detected