betanet-mini-ui
Version:
为 Taro 而设计的 UI Library
34 lines (29 loc) • 827 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.uuid = uuid;
function uuid() {
var len = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 8;
var radix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 16;
var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
var value = [];
var i = 0;
radix = radix || chars.length;
if (len) {
for (i = 0; i < len; i++) {
value[i] = chars[0 | Math.random() * radix];
}
} else {
var r;
value[8] = value[13] = value[18] = value[23] = '-';
value[14] = '4';
for (i = 0; i < 36; i++) {
if (!value[i]) {
r = 0 | Math.random() * 16;
value[i] = chars[i === 19 ? r & 0x3 | 0x8 : r];
}
}
}
return value.join('');
}