@tpacks/flexigrid
Version:
A library helps you make a grid with resizable and movable panes on it, just like Kibana dashboard
22 lines (19 loc) • 514 B
JavaScript
let asciiDecoder = null;
if (window.TextDecoder) {
asciiDecoder = new window.TextDecoder('ascii');
} else {
throw new Error('GenID: No Text decoder in this browser');
}
module.exports = {
genid(length = 16) {
if (asciiDecoder) {
if (window.crypto) {
let ui8 = new Uint8Array(length);
ui8 = window.crypto.getRandomValues(ui8);
return asciiDecoder.decode(ui8);
} else {
throw new Error('GenID: This browser does not support Crypto API');
}
}
},
};