util-helpers
Version:
26 lines (25 loc) • 807 B
TypeScript
interface RandomString {
(len: number, poll: 'number' | 'lower' | 'upper'): string;
(len: number, poll?: string): string;
}
/**
* 生成随机字符串
*
* @function
* @alias module:Other.randomString
* @since 4.8.0
* @param {number} [len=0] 长度,默认`0`
* @param {'number' | 'lower' | 'upper' | string} [pool='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'] 字符池,默认为数字和大小写字母。支持设置类型`number` `lower` `upper` 或字符串。
* @returns {string} 随机字符串
* @example
*
* randomString(5); // slk23
* randomString(8); // 71mHqo2A
*
* // 自定义允许的字符
* randomString(5, 'abc'); // ccbcb
* randomString(8, 'abcefg'); // bcgcfabg
*
*/
declare const randomString: RandomString;
export default randomString;