All files / str getRnd36.ts

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

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                    1x 3x 3x     1x  
/**
 * 获取36进制随机字符串
 * @method getRnd36
 * @param {Float} [rnd] 随机数,不传则生成一个随机数
 * @return {String} 转成为36进制的字符串
 * @example
 * import { getRnd36 } from '@spore-ui/tskit';
 * getRnd36(0.5810766832590446); // 'kx2pozz9rgf'
 */
 
export function getRnd36(rnd?: number): string {
  const rndigit = rnd || Math.random();
  return rndigit.toString(36).replace(/^0./, '');
}
 
export default getRnd36;