randomUintString()
function randomUintString(length?): string;
Defined in: random/randomUintString.ts:18
生成指定长度的随机数字字符串,第一位不为 0 适用于生成数字 ID 或序列号,确保不会以 0 开头
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
length | number | 16 | 字符串长度,默认 16 |
Returns
string
指定长度的随机数字字符串
Examples
randomUintString(3); // 返回 3 位数字字符串,如 '123'、'456'、'789'
randomUintString(1); // 返回 1 位数字字符串,如 '1'、'2'、'3'...'9'
randomUintString(5); // 返回 5 位数字字符串,如 '12345'
**Note:** 第一位使用 NUMBER_WITHOUT_ZERO(1-9),其余位使用 NUMBERS(0-9)
**Note:** 确保生成的字符串可以安全转换为正整数
**Note:** 适用于生成唯一标识符或序列号