{"_id":"prng-well1024a","_rev":"11-15404d727c68fa8f67ca6b0fb7cbbfcb","name":"prng-well1024a","description":"Random number generator based on WELL-1024a algorithm.","dist-tags":{"latest":"2.0.0"},"versions":{"1.0.0":{"name":"prng-well1024a","version":"1.0.0","description":"Random number generator based on WELL-1024a algorithm.","main":"well1024a.js","scripts":{"test":"node_modules/mocha/bin/mocha","prepublish":"npm test && npm run-script browser && npm run-script test-distribution && echo Prepublish Checks OK","browser":"node ./bundle.js && node_modules/uglify-js/bin/uglifyjs --unsafe -o browser/well1024a.min.js browser/well1024a.js","test-distribution":"node_modules/mocha/bin/mocha -R landing -t 300000 -s 300000 test-distribution/","prepare-webclient-tests":"git submodule update --init --recursive"},"repository":{"type":"git","url":"http://github.com/deestan/well1024a.git"},"keywords":["prng","rng","random"],"devDependencies":{"mocha":"~1.2.0","uglify-js":"~1.3.0"},"author":{"name":"Helge Skogly Holm","email":"helge.holm@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/deestan/well1024a/issues"},"_id":"prng-well1024a@1.0.0","dist":{"shasum":"bf487d3c8dfd6102561f467634db78cd74da56a4","tarball":"https://registry.npmjs.org/prng-well1024a/-/prng-well1024a-1.0.0.tgz","integrity":"sha512-rctHiKqaJpC8gXGVVVhba+frmMT21mmhjgs2iOpDEboWwdq691twz4t6YjvlOADsSBDrrVzyMjBjBre/cHz3iA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBNp628LIakM/qB6B/agwb5OG6ww/ULedsPDwZMZK4HJAiEAxvkJpvnIiuKlPW2dDfNK5eoeNHdRXXmSjqKT9tdufy8="}]},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"deestan","email":"helge.holm@gmail.com"},"maintainers":[{"name":"deestan","email":"helge.holm@gmail.com"}]},"1.0.1":{"name":"prng-well1024a","version":"1.0.1","description":"Random number generator based on WELL-1024a algorithm.","main":"well1024a.js","scripts":{"test":"node_modules/mocha/bin/mocha","prepublish":"npm test && npm run-script browser && npm run-script test-distribution && echo Prepublish Checks OK","browser":"node ./bundle.js && node_modules/uglify-js/bin/uglifyjs --unsafe -o browser/well1024a.min.js browser/well1024a.js","test-distribution":"node_modules/mocha/bin/mocha -R landing -t 300000 -s 300000 test-distribution/","prepare-webclient-tests":"git submodule update --init --recursive"},"repository":{"type":"git","url":"http://github.com/deestan/well1024a.git"},"keywords":["prng","rng","random"],"devDependencies":{"mocha":"~1.2.0","uglify-js":"~1.3.0"},"author":{"name":"Helge Skogly Holm","email":"helge.holm@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/deestan/well1024a/issues"},"_id":"prng-well1024a@1.0.1","dist":{"shasum":"05e8ed923e4ea2b3f78af5ee94f056b4d5cfab24","tarball":"https://registry.npmjs.org/prng-well1024a/-/prng-well1024a-1.0.1.tgz","integrity":"sha512-lBXfAW5Vgpej/QVHNYhTSsiz1IIlgo7kv8zzQL7v5crD8jgA4Fk3axwb9aCrDHUqJ4zKXsb3U3m6sw21165Trg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDTevXcX8Tv8933XD7NIvJDQkjN8d5ZnlImdgBIcjefmAIhAPsRvjWA7bkOh+QP6uIBMk1GpyRYX9OKHvBqSxj4Q0v7"}]},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"deestan","email":"helge.holm@gmail.com"},"maintainers":[{"name":"deestan","email":"helge.holm@gmail.com"}]},"2.0.0":{"name":"prng-well1024a","version":"2.0.0","description":"Random number generator based on WELL-1024a algorithm.","main":"well1024a.js","scripts":{"test":"node_modules/mocha/bin/mocha","prepublish":"npm test && npm run-script browser && npm run-script test-distribution && echo Prepublish Checks OK","browser":"node ./bundle.js && node_modules/uglify-js/bin/uglifyjs --unsafe -o browser/well1024a.min.js browser/well1024a.js","test-distribution":"node_modules/mocha/bin/mocha -R landing -t 300000 -s 300000 test-distribution/","prepare-webclient-tests":"git submodule update --init --recursive"},"repository":{"type":"git","url":"http://github.com/deestan/well1024a.git"},"keywords":["prng","rng","random"],"devDependencies":{"mocha":"~1.2.0","uglify-js":"~1.3.0"},"author":{"name":"Helge Skogly Holm","email":"helge.holm@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/deestan/well1024a/issues"},"gitHead":"886dd97169e1d238991c8b22ffa8d07c1d85d7b9","homepage":"https://github.com/deestan/well1024a","_id":"prng-well1024a@2.0.0","_shasum":"52a40ae9a8f8306f20d2f34002a1b1f144b3475f","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"deestan","email":"helge.holm@gmail.com"},"maintainers":[{"name":"deestan","email":"helge.holm@gmail.com"}],"dist":{"shasum":"52a40ae9a8f8306f20d2f34002a1b1f144b3475f","tarball":"https://registry.npmjs.org/prng-well1024a/-/prng-well1024a-2.0.0.tgz","integrity":"sha512-p9FuOYh9ej61bCaw2SkX8+6+bcZVUa/x2DgXkjZYzKO6kX8nGsxcc1m0urJXTZ826mCdPYJ/oSEXb4+Wi4iQDw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHU2e4Ad6s7SJr+RDzn+67QcS2WyekPhjnuUPpKrrSuYAiBvLWpMJwtWuowihKqN0yEUhtYshxj+X69d+v5RV4wgtw=="}]}}},"readme":"# well1024a.js\n\n[![NPM](https://nodei.co/npm/prng-well1024a.png)](https://nodei.co/npm/prng-well1024a/)\n\nThis is a Javascript implementation of the\n[WELL-1024a](http://en.wikipedia.org/wiki/Well_equidistributed_long-period_linear)\npseudorandom number generation algorithm.\n\nJavascript's built-in `Math.random()` function is\n[implementation-dependent](http://www.ecma-international.org/publications/standards/Ecma-262.htm)\nand therefore of limited usefulness if your program depends on random\nnumbers, as you risk running into crappy implementations.  Even the V8\nengine (used by Node.js) only provides 32-bit entropy, and is based on\nthe platform-dependent C++ `rand()` function.\n\nThis module is very bare-bones.  I have also written a randomness library called\n[randy](http://github.com/deestan/randy.git) that provides useful functions like\n`RandInt(min, max)`, `shuffle(array)` etc., based on this module.\n\n## Quick Example\n\n```javascript\nvar rng = well1024a();\nvar number = rng.getUInt32();\nvar coin = ['heads', 'tails'][number % 2];\n// coin == 'heads'\n```\n\n<a name=\"Download\" />\n## Download\n\nFor [Node.js](http://nodejs.org/), use [npm](http://npmjs.org/):\n\n    npm install prng-well1024a\n\n<a name=\"browser\" />\n### In the Browser\n\nDownload and include as a `<script>`.  The module will be available as\nthe global object `randy`.\n\n__Development:__ [well1024a.js](https://github.com/deestan/well1024a/raw/master/browser/well1024a.js) - 2Kb Uncompressed\n\n__Production:__ [well1024a.min.js](https://github.com/deestan/well1024a/raw/master/browser/well1024a.min.js) - < 1Kb Minified\n\n__Example__\n\n```html\n<script src=\"well1024a.min.js\"></script>\n\nI am <span id=\"age\"></span> years old!\n\n<script>\n    var n = document.getElementById(\"age\");\n    var myAge = well1024a.getUInt32();\n    n.innerText = myAge.toString();\n</script>\n```\n\n## Documentation\n\n### Constructor\n\n* [well1024a](#well1024a)\n\n### Instance Functions\n\n* [getUInt32](#getUInt32)\n* [getState](#getstate)\n* [setState](#setState)\n\n-----------------------------------\n\n<a name=\"well1024a\" />\n## well1024a(entropy)\n## well1024a()\n\nReturns a new well1024a instance, which is an object with 3 functions:\n\n* [getUInt32](#getUInt32)\n* [getState](#getstate)\n* [setState](#setState)\n\nThe instance will use `Math.random()` to fill out the initial seed state.\n\n__Arguments__\n\n* entropy - default=[].  Array of numbers to add to the initial seed.  These should be based on environmental values that are likely to be different on each run such as system time, process ID, browser window height, values from `/dev/urandom` etc.\n\n__Example__\n\n```javascript\nvar w = well1024a([\n    Date.now(),\n    os.freemem(),\n    process.pid\n]);\n```\n\n-----------------------------------\n\n<a name=\"getUInt32\" />\n## getUInt32()\n\nReturns a random positive integer less than 2^32.\n\n__Example__\n\n```javascript\nvar w = well1024a();\n\nconsole.log('For Christmas this year, I want ' + w.getUInt32().toString() + ' ponies!');\n```\n\n-----------------------------------\n\n<a name=\"getState\" />\n## getState()\n\nReturns an array of 32-bit unsigned integers, of length 32.  This represents the current state of the random number generator.\n\nThis array can be used as a parameter to `setState`.\n\n-----------------------------------\n\n<a name=\"setState\" />\n## setState(state)\n\nSets the random number generator to a specific state, allowing for replay of random values.\n\nGeneral use case is to give it a value previously received by calling `getState()`.\n\n__Arguments__\n\n* state - Must be an array of 32-bit unsigned integers, of length 32.\n\n__Example__\n\nThis will flip a pair of coins, reset the generator state, and flip the\ncoins again with the exact same output.\n\n```javascript\nvar w = well1024a();\nvar coins = ['heads', 'tails'];\n\nconsole.log(\"Flippin' the coins:\");\nvar state = w.getState();\nvar d1 = coins[w.getUInt32() % 2];\nvar d2 = coins[w.getUInt32() % 2];\nconsole.log(d1 + \" and \" + d2);\n\nconsole.log(\"Instant replay:\");\nw.setState(state);\nd1 = coins[w.getUInt32() % 2];\nd2 = coins[w.getUInt32() % 2];\nconsole.log(d1 + \" and \" + d2);\n```\n\n---------------------------------------\n\n## Notes\n\nNo functions rely on `this`, so it's safe to e.g. assign\n`randy.good.randInt` to a variable or pass it around as a\nparameter.\n","maintainers":[{"name":"deestan","email":"helge.holm@gmail.com"}],"time":{"modified":"2022-06-24T16:38:22.745Z","created":"2014-05-24T01:25:45.487Z","1.0.0":"2014-05-24T01:25:49.034Z","1.0.1":"2014-05-24T01:39:50.146Z","2.0.0":"2015-09-09T11:01:45.617Z"},"readmeFilename":"README.md","keywords":["prng","rng","random"],"repository":{"type":"git","url":"http://github.com/deestan/well1024a.git"},"author":{"name":"Helge Skogly Holm","email":"helge.holm@gmail.com"},"bugs":{"url":"https://github.com/deestan/well1024a/issues"},"license":"MIT","homepage":"https://github.com/deestan/well1024a"}