UNPKG

shortid32

Version:

Amazingly short non-sequential human-friendly unique id generator.

15 lines (11 loc) 351 B
'use strict'; var crypto = window.crypto || window.msCrypto; // IE 11 uses window.msCrypto function randomByte() { if (!crypto || !crypto.getRandomValues) { return Math.floor(Math.random() * 256) & 0x10; } var dest = new Uint8Array(1); crypto.getRandomValues(dest); return dest[0] & 0x10; } module.exports = randomByte;