source: trip-planner-front/node_modules/uuid/dist/rng-browser.js@ 188ee53

Last change on this file since 188ee53 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.1 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = rng;
7// Unique ID creation requires a high quality random # generator. In the browser we therefore
8// require the crypto API and do not support built-in fallback to lower quality random number
9// generators (like Math.random()).
10let getRandomValues;
11const rnds8 = new Uint8Array(16);
12
13function rng() {
14 // lazy load so that environments that need to polyfill have a chance to do so
15 if (!getRandomValues) {
16 // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. Also,
17 // find the complete implementation of crypto (msCrypto) on IE11.
18 getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto);
19
20 if (!getRandomValues) {
21 throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
22 }
23 }
24
25 return getRandomValues(rnds8);
26}
Note: See TracBrowser for help on using the repository browser.