jr-util
Version:
这是MJR的JS工具库。定期更新
35 lines (34 loc) • 1.1 kB
JavaScript
const i = () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(t) {
var r = Math.random() * 16 | 0, o = t == "x" ? r : r & 3 | 8;
return o.toString(16);
});
function u(t, r) {
const o = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""), n = [];
if (r = r || o.length, t)
for (let e = 0; e < t; e++)
n[e] = o[0 | Math.random() * r];
else {
let e;
n[8] = n[13] = n[18] = n[23] = "-", n[14] = "4";
for (let x = 0; x < 36; x++)
n[x] || (e = 0 | Math.random() * 16, n[x] = o[x === 19 ? e & 3 | 8 : e]);
}
return n.join("") + new Date().getTime();
}
function s() {
const t = +new Date() + "";
return (+(parseInt((1 + Math.random()) * 65536 + "") + "" + t)).toString(32).toUpperCase();
}
function c(t, r) {
return Math.floor(Math.random() * (r + 1 - t) + t);
}
function a(t = 10) {
return (t <= 11 ? Math.random().toString(36).slice(2, 2 + t).padEnd(t, "0") : a(11) + a(t - 11)).toLocaleUpperCase();
}
export {
c as getIntervalNum,
a as getRandomSting,
i as getUUid,
u as getUUidByChar,
s as getUUidByDate
};