rng.js 525 B

1234567891011121314
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. let getRandomValues;
  4. const rnds8 = new Uint8Array(16);
  5. function rng() {
  6. if (!getRandomValues) {
  7. if (typeof crypto === 'undefined' || !crypto.getRandomValues) {
  8. throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
  9. }
  10. getRandomValues = crypto.getRandomValues.bind(crypto);
  11. }
  12. return getRandomValues(rnds8);
  13. }
  14. exports.default = rng;