All files / str getRnd36.js

100% Statements 3/3
100% Branches 2/2
100% Functions 1/1
100% Lines 3/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17                      3x 3x     1x  
/**
 * 获取36进制随机字符串
 * @method str/getRnd36
 * @param {Float} [rnd] 随机数,不传则生成一个随机数
 * @return {String} 转成为36进制的字符串
 * @example
 * var $getRnd36 = require('@spore-ui/kit/packages/str/getRnd36');
 * $getRnd36(0.5810766832590446); // 'kx2pozz9rgf'
 */
 
function getRnd36(rnd) {
  rnd = rnd || Math.random();
  return rnd.toString(36).replace(/^0./, '');
}
 
module.exports = getRnd36;