RandomUtil

RandomUtil

new RandomUtil()

Source:
Author:
  • ycx
随机数工具类

Methods

(static) randomEle(arr, limit) → {*}

Source:
从前几个数组中随机获取 一个元素
Parameters:
Name Type Description
arr Array.<*> 数组对象
limit number 限制的前n项
Returns:
数组中的某个元素或者null
Type
*

(static) randomEnStr(length) → {string}

Source:
从A-Za-z0-9中获取指定长度的字符串
Parameters:
Name Type Description
length 长度
Returns:
字符串
Type
string

(static) randomInt(min, max) → {number}

Source:
获取随机范围的int数值 包含min 不包含max
Parameters:
Name Type Description
min number 最小数
max number 最大数
Returns:
随机整数
Type
number

(static) randomStr(str, length) → {string|null}

Source:
从指定字符串中随机获取字符串 e.g. 'abcdefg'中获取长度为3随机字符串 ‘afg’;
Parameters:
Name Type Description
str string
length number 随机字符串的长度
Returns:
字符串或null
Type
string | null