PageSourceSearch

https://dorsetcountymuseum.org/packages/random.js?hash=e2a12c757e38980def020ea948604f8b19f15e90

js dorsetcountymuseum.org collected 2026-09-24 09:57:01 UTC 16,522 bytes, 470 lines download raw bytes

1//////////////////////////////////////////////////////////////////////////
2//                                                                      //
3// This is a generated file. You can view the original                  //
4// source in your browser if your browser supports source maps.         //
5// Source maps are supported by all recent versions of Chrome, Safari,  //
6// and Firefox, and by Internet Explorer 11.                            //
7//                                                                      //
8//////////////////////////////////////////////////////////////////////////
9
10
11Package["core-runtime"].queue("random",function () {/* Imports */
12var Meteor = Package.meteor.Meteor;
13var global = Package.meteor.global;
14var meteorEnv = Package.meteor.meteorEnv;
15var meteorInstall = Package.modules.meteorInstall;
16var meteorBabelHelpers = Package.modules.meteorBabelHelpers;
17var Promise = Package.promise.Promise;
18var Symbol = Package['ecmascript-runtime-client'].Symbol;
19var Map = Package['ecmascript-runtime-client'].Map;
20var Set = Package['ecmascript-runtime-client'].Set;
21
22/* Package-scope variables */
23var Random;
24
25var require = meteorInstall({"node_modules":{"meteor":{"random":{
25"main_client.js":function module(require,exports,module){
26
27//////////////////////////////////////////////////////////////////////////////////////////////////
28//                                                                                              //
29// packages/random/main_client.js                                                               //
30//                                                                                              //
31//////////////////////////////////////////////////////////////////////////////////////////////////
32                                                                                                //
33module.export({
34  Random: function () {
35    return Random;
36  }
37});
38var BrowserRandomGenerator;
39module.link("./BrowserRandomGenerator", {
40  "default": function (v) {
41    BrowserRandomGenerator = v;
42  }
43}, 0);
44var createAleaGeneratorWithGeneratedSeed;
45module.link("./createAleaGenerator", {
46  "default": function (v) {
47    createAleaGeneratorWithGeneratedSeed = v;
48  }
49}, 1);
50var createRandom;
51module.link("./createRandom", {
52  "default": function (v) {
53    createRandom = v;
54  }
55}, 2);
56var generator;
57if (typeof window !== 'undefined' && window.crypto && window.crypto.getRandomValues) {
58  generator = new BrowserRandomGenerator();
59} else {
60  // On IE 10 and below, there's no browser crypto API
61  // available. Fall back to Alea
62  //
63  // XXX looks like at the moment, we use Alea in IE 11 as well,
64  // which has `window.msCrypto` instead of `window.crypto`.
65  generator = createAleaGeneratorWithGeneratedSeed();
66}
67var Random = createRandom(generator);
68//////////////////////////////////////////////////////////////////////////////////////////////////
69
70},
70"AbstractRandomGenerator.js":function module(require,exports,module){
71
72//////////////////////////////////////////////////////////////////////////////////////////////////
73//                                                                                              //
74// packages/random/AbstractRandomGenerator.js                                                   //
75//                                                                                              //
76//////////////////////////////////////////////////////////////////////////////////////////////////
77                                                                                                //
78module.export({
79  "default": function () {
80    return RandomGenerator;
81  }
82});
83var Meteor;
84module.link("meteor/meteor", {
85  Meteor: function (v) {
86    Meteor = v;
87  }
88}, 0);
89var UNMISTAKABLE_CHARS = '23456789ABCDEFGHJKLMNPQRSTWXYZabcdefghijkmnopqrstuvwxyz';
90var BASE64_CHARS = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' + '0123456789-_';
91
92// `type` is one of `RandomGenerator.Type` as defined below.
93//
94// options:
95// - seeds: (required, only for RandomGenerator.Type.ALEA) an array
96//   whose items will be `toString`ed and used as the seed to the Alea
97//   algorithm
98var RandomGenerator = /*#__PURE__*/function () {
99  function RandomGenerator() {}
100  var _proto = RandomGenerator.prototype;
101  /**
102   * @name Random.fraction
103   * @summary Return a number between 0 and 1, like `Math.random`.
104   * @locus Anywhere
105   */
106  _proto.fraction = function () {
107    function fraction() {
108      throw new Error("Unknown random generator type");
109    }
110    return fraction;
111  }()
112  /**
113   * @name Random.hexString
114   * @summary Return a random string of `n` hexadecimal digits.
115   * @locus Anywhere
116   * @param {Number} n Length of the string
117   */
118  ;
119  _proto.hexString = function () {
120    function hexString(digits) {
121      return this._randomString(digits, '0123456789abcdef');
122    }
123    return hexString;
124  }();
125  _proto._randomString = function () {
126    function _randomString(charsCount, alphabet) {
127      var result = '';
128      for (var i = 0; i < charsCount; i++) {
129        result += this.choice(alphabet);
130      }
131      return result;
132    }
133    return _randomString;
134  }()
135  /**
136   * @name Random.id
137   * @summary Return a unique identifier, such as `"Jjwjg6gouWLXhMGKW"`, that is
138   * likely to be unique in the whole world.
139   * @locus Anywhere
140   * @param {Number} [n] Optional length of the identifier in characters
141   *   (defaults to 17)
142   */
143  ;
144  _proto.id = function () {
145    function id(charsCount) {
146      // 17 characters is around 96 bits of entropy, which is the amount of
147      // state in the Alea PRNG.
148      if (charsCount === undefined) {
149        charsCount = 17;
150      }
151      return this._randomString(charsCount, UNMISTAKABLE_CHARS);
152    }
153    return id;
154  }()
155  /**
156   * @name Random.secret
157   * @summary Return a random string of printable characters with 6 bits of
158   * entropy per character. Use `Random.secret` for security-critical secrets
159   * that are intended for machine, rather than human, consumption.
160   * @locus Anywhere
161   * @param {Number} [n] Optional length of the secret string (defaults to 43
162   *   characters, or 256 bits of entropy)
163   */
164  ;
165  _proto.secret = function () {
166    function secret(charsCount) {
167      // Default to 256 bits of entropy, or 43 characters at 6 bits per
168      // character.
169      if (charsCount === undefined) {
170        charsCount = 43;
171      }
172      return this._randomString(charsCount, BASE64_CHARS);
173    }
174    return secret;
175  }()
176  /**
177   * @name Random.choice
178   * @summary Return a random element of the given array or string.
179   * @locus Anywhere
180   * @param {Array|String} arrayOrString Array or string to choose from
181   */
182  ;
183  _proto.choice = function () {
184    function choice(arrayOrString) {
185      var index = Math.floor(this.fraction() * arrayOrString.length);
186      if (typeof arrayOrString === 'string') {
187        return arrayOrString.substr(index, 1);
188      }
189      return arrayOrString[index];
190    }
191    return choice;
192  }();
193  return RandomGenerator;
194}();
195//////////////////////////////////////////////////////////////////////////////////////////////////
196
197},
197"AleaRandomGenerator.js":function module(require,exports,module){
198
199//////////////////////////////////////////////////////////////////////////////////////////////////
200//                                                                                              //
201// packages/random/AleaRandomGenerator.js                                                       //
202//                                                                                              //
203//////////////////////////////////////////////////////////////////////////////////////////////////
204                                                                                                //
205var _inheritsLoose;
206module.link("@babel/runtime/helpers/inheritsLoose", {
207  default: function (v) {
208    _inheritsLoose = v;
209  }
210}, 0);
211module.export({
212  "default": function () {
213    return AleaRandomGenerator;
214  }
215});
216var RandomGenerator;
217module.link("./AbstractRandomGenerator", {
218  "default": function (v) {
219    RandomGenerator = v;
220  }
221}, 0);
222// Alea PRNG, which is not cryptographically strong
223// see http://baagoe.org/en/wiki/Better_random_numbers_for_javascript
224// for a full discussion and Alea implementation.
225function Alea(seeds) {
226  function Mash() {
227    var n = 0xefc8249d;
228    var mash = function (data) {
229      data = data.toString();
230      for (var i = 0; i < data.length; i++) {
231        n += data.charCodeAt(i);
232        var h = 0.02519603282416938 * n;
233        n = h >>> 0;
234        h -= n;
235        h *= n;
236        n = h >>> 0;
237        h -= n;
238        n += h * 0x100000000; // 2^32
239      }
240      return (n >>> 0) * 2.3283064365386963e-10; // 2^-32
241    };
242    mash.version = 'Mash 0.9';
243    return mash;
244  }
245  var s0 = 0;
246  var s1 = 0;
247  var s2 = 0;
248  var c = 1;
249  if (seeds.length === 0) {
250    seeds = [+new Date()];
251  }
252  var mash = Mash();
253  s0 = mash(' ');
254  s1 = mash(' ');
255  s2 = mash(' ');
256  for (var i = 0; i < seeds.length; i++) {
257    s0 -= mash(seeds[i]);
258    if (s0 < 0) {
259      s0 += 1;
260    }
261    s1 -= mash(seeds[i]);
262    if (s1 < 0) {
263      s1 += 1;
264    }
265    s2 -= mash(seeds[i]);
266    if (s2 < 0) {
267      s2 += 1;
268    }
269  }
270  mash = null;
271  var random = function () {
272    var t = 2091639 * s0 + c * 2.3283064365386963e-10; // 2^-32
273    s0 = s1;
274    s1 = s2;
275    return s2 = t - (c = t | 0);
276  };
277  random.uint32 = function () {
278    return random() * 0x100000000;
279  }; // 2^32
280  random.fract53 = function () {
281    return random() + (random() * 0x200000 | 0) * 1.1102230246251565e-16;
282  }; // 2^-53
283
284  random.version = 'Alea 0.9';
285  random.args = seeds;
286  return random;
287}
288
289// options:
290// - seeds: an array
291//   whose items will be `toString`ed and used as the seed to the Alea
292//   algorithm
293var AleaRandomGenerator = /*#__PURE__*/function (_RandomGenerator) {
294  function AleaRandomGenerator() {
295    var _this;
296    var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
297      _ref$seeds = _ref.seeds,
298      seeds = _ref$seeds === void 0 ? [] : _ref$seeds;
299    _this = _RandomGenerator.call(this) || this;
300    if (!seeds) {
301      throw new Error('No seeds were provided for Alea PRNG');
302    }
303    _this.alea = Alea(seeds);
304    return _this;
305  }
306
307  /**
308   * @name Random.fraction
309   * @summary Return a number between 0 and 1, like `Math.random`.
310   * @locus Anywhere
311   */
312  _inheritsLoose(AleaRandomGenerator, _RandomGenerator);
313  var _proto = AleaRandomGenerator.prototype;
314  _proto.fraction = function () {
315    function fraction() {
316      return this.alea();
317    }
318    return fraction;
319  }();
320  return AleaRandomGenerator;
321}(RandomGenerator);
322//////////////////////////////////////////////////////////////////////////////////////////////////
323
324},
324"BrowserRandomGenerator.js":function module(require,exports,module){
325
326//////////////////////////////////////////////////////////////////////////////////////////////////
327//                                                                                              //
328// packages/random/BrowserRandomGenerator.js                                                    //
329//                                                                                              //
330//////////////////////////////////////////////////////////////////////////////////////////////////
331                                                                                                //
332var _inheritsLoose;
333module.link("@babel/runtime/helpers/inheritsLoose", {
334  default: function (v) {
335    _inheritsLoose = v;
336  }
337}, 0);
338module.export({
339  "default": function () {
340    return BrowserRandomGenerator;
341  }
342});
343var RandomGenerator;
344module.link("./AbstractRandomGenerator", {
345  "default": function (v) {
346    RandomGenerator = v;
347  }
348}, 0);
349var BrowserRandomGenerator = /*#__PURE__*/function (_RandomGenerator) {
350  function BrowserRandomGenerator() {
351    return _RandomGenerator.apply(this, arguments) || this;
352  }
353  _inheritsLoose(BrowserRandomGenerator, _RandomGenerator);
354  var _proto = BrowserRandomGenerator.prototype;
355  /**
356   * @name Random.fraction
357   * @summary Return a number between 0 and 1, like `Math.random`.
358   * @locus Anywhere
359   */
360  _proto.fraction = function () {
361    function fraction() {
362      var array = new Uint32Array(1);
363      window.crypto.getRandomValues(array);
364      return array[0] * 2.3283064365386963e-10; // 2^-32
365    }
366    return fraction;
367  }();
368  return BrowserRandomGenerator;
369}(RandomGenerator);
370//////////////////////////////////////////////////////////////////////////////////////////////////
371
372},
372"createAleaGenerator.js":function module(require,exports,module){
373
374//////////////////////////////////////////////////////////////////////////////////////////////////
375//                                                                                              //
376// packages/random/createAleaGenerator.js                                                       //
377//                                                                                              //
378//////////////////////////////////////////////////////////////////////////////////////////////////
379                                                                                                //
380module.export({
381  "default": function () {
382    return createAleaGenerator;
383  }
384});
385var AleaRandomGenerator;
386module.link("./AleaRandomGenerator", {
387  "default": function (v) {
388    AleaRandomGenerator = v;
389  }
390}, 0);
391// instantiate RNG.  Heuristically collect entropy from various sources when a
392// cryptographic PRNG isn't available.
393
394// client sources
395var height = typeof window !== 'undefined' && window.innerHeight || typeof document !== 'undefined' && document.documentElement && document.documentElement.clientHeight || typeof document !== 'undefined' && document.body && document.body.clientHeight || 1;
396var width = typeof window !== 'undefined' && window.innerWidth || typeof document !== 'undefined' && document.documentElement && document.documentElement.clientWidth || typeof document !== 'undefined' && document.body && document.body.clientWidth || 1;
397var agent = typeof navigator !== 'undefined' && navigator.userAgent || '';
398function createAleaGenerator() {
399  return new AleaRandomGenerator({
400    seeds: [new Date(), height, width, agent, Math.random()]
401  });
402}
403//////////////////////////////////////////////////////////////////////////////////////////////////
404
405},
405"createRandom.js":function module(require,exports,module){
406
407//////////////////////////////////////////////////////////////////////////////////////////////////
408//                                                                                              //
409// packages/random/createRandom.js                                                              //
410//                                                                                              //
411//////////////////////////////////////////////////////////////////////////////////////////////////
412                                                                                                //
413module.export({
414  "default": function () {
415    return createRandom;
416  }
417});
418var AleaRandomGenerator;
419module.link("./AleaRandomGenerator", {
420  "default": function (v) {
421    AleaRandomGenerator = v;
422  }
423}, 0);
424var createAleaGeneratorWithGeneratedSeed;
425module.link("./createAleaGenerator", {
426  "default": function (v) {
427    createAleaGeneratorWithGeneratedSeed = v;
428  }
429}, 1);
430function createRandom(generator) {
431  // Create a non-cryptographically secure PRNG with a given seed (using
432  // the Alea algorithm)
433  generator.createWithSeeds = function () {
434    for (var _len = arguments.length, seeds = new Array(_len), _key = 0; _key < _len; _key++) {
435      seeds[_key] = arguments[_key];
436    }
437    if (seeds.length === 0) {
438      throw new Error('No seeds were provided');
439    }
440    return new AleaRandomGenerator({
441      seeds: seeds
442    });
443  };
444
445  // Used like `Random`, but much faster and not cryptographically
446  // secure
447  generator.insecure = createAleaGeneratorWithGeneratedSeed();
448  return generator;
449}
450//////////////////////////////////////////////////////////////////////////////////////////////////
451
452}
452}}}},{
453  "extensions": [
454    ".js",
455    ".json"
456  ]
457});
458
459
460/* Exports */
461return {
462  export: function () { return {
463      Random: Random
464    };},
465  require: require,
466  eagerModulePaths: [
467    "/node_modules/meteor/random/main_client.js"
468  ],
469  mainModulePath: "/node_modules/meteor/random/main_client.js"
470}});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.