JavaScript Restrictor
Browser extension that improves privacy and security
|
Random number generator. More...
Variables | |
var | alea |
Random number generator.
A port of an algorithm by Johannes Baagøe baago.nosp@m.e@ba.nosp@m.agoe..nosp@m.com, 2010 and Tommy Ettinger (tommy.nosp@m..ett.nosp@m.inger.nosp@m.@gma.nosp@m.il.co.nosp@m.m)
Original code is available at http://baagoe.com/en/RandomMusings/javascript/ https://github.com/nquinlan/better-random-numbers-for-javascript-mirror https://gist.github.com/tommyettinger/46a874533244883189143505d203312c
SPDX-License-Identifier: GPL-3.0-or-later SPDX-License-Identifier: MIT
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.
var alea |
alea creates a function that is functionally equivalent to Math.random.
That is, successive calls of the returned function return Number values with positive sign, greater than or equal to 0 but less than 1, chosen pseudo-randomly with approximately uniform distribution over that range.
The internal state of random, and hence the sequence of pseudo-random numbers it returns, is determined by the arguments to alea. Two functions returned by calls to alea with the same argument values will return exactly the same sequence of pseudo-random numbers. String and Number arguments should provide repeatable output across platforms. Object arguments[3] provide repeatable output on the same platform, but not necessarily on others.
Please call alea() with at least one argument, the implementation with nno arguments described by Baagøe was not implemented here. This provides easy means to provide somewhat unpredictable numbers, like Math.random does.
Example usage: let module_prng = alea(domainHash, "MyModuleName"); module_prng();
See more details in the README.md at https://github.com/nquinlan/better-random-numbers-for-javascript-mirror