const uuid = (n = 6) => {
if (n < 2) {
throw new RangeError('n is not less than 2');
}
const CHARS = 'abcdefghigklmnopqrstuvwxyz';
const NUMS = '0123456789';
const ALL = CHARS + NUMS;
let repeatStr = '';
for (let i = 0; i < n - 2; i++) {
repeatStr += 'z';
}
return `xx${repeatStr}`.replace(/[xz]/g, (c) =>
c === 'x' ? CHARS[(Math.random() * 26) | 0] : ALL[(Math.random() * 36) | 0],
);
};