{"_id":"knuth-shuffle","_rev":"2784402","name":"knuth-shuffle","description":"The Fisher-Yates (aka Knuth) shuffle for Browser and Node.js","dist-tags":{"latest":"1.0.8"},"maintainers":[{"name":"coolaj86","email":""}],"time":{"modified":"2022-06-13T06:12:47.000Z","created":"2013-12-03T07:50:34.826Z","1.0.8":"2017-10-29T04:12:30.880Z","1.0.1":"2014-09-28T09:22:27.539Z","1.0.0":"2013-12-03T07:50:34.826Z"},"users":{},"author":{"name":"AJ ONeal","email":"coolaj86@gmail.com","url":"https://coolaj86.com/"},"repository":{"type":"git","url":"git://git.coolaj86.com:coolaj86/knuth-shuffle.js.git"},"versions":{"1.0.8":{"name":"knuth-shuffle","version":"1.0.8","description":"The Fisher-Yates (aka Knuth) shuffle for Browser and Node.js","main":"index.js","homepage":"https://git.coolaj86.com/coolaj86/knuth-shuffle.js","scripts":{"test":"node example.js"},"repository":{"type":"git","url":"git://git.coolaj86.com:coolaj86/knuth-shuffle.js.git"},"keywords":["ronald","fisher","frank","yates","fisher-yates","donald","knuth","shuffle","random","randomize","unbiased","algorithm"],"author":{"name":"AJ ONeal","email":"coolaj86@gmail.com","url":"https://coolaj86.com/"},"license":"(MIT OR Apache-2.0)","bugs":{"url":"https://git.coolaj86.com/coolaj86/knuth-shuffle/issues"},"gitHead":"c60dcd6828e06db624a8d615ef890329a3081979","_id":"knuth-shuffle@1.0.8","_npmVersion":"5.4.2","_nodeVersion":"8.8.1","_npmUser":{"name":"coolaj86","email":"coolaj86@gmail.com"},"dist":{"shasum":"929a467b0efd8d297bdcf318ca988a9f1037f80d","size":5849,"noattachment":false,"key":"/knuth-shuffle/-/knuth-shuffle-1.0.8.tgz","tarball":"http://registry.cnpm.dingdandao.com/knuth-shuffle/download/knuth-shuffle-1.0.8.tgz"},"maintainers":[{"name":"coolaj86","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/knuth-shuffle-1.0.8.tgz_1509250350769_0.6957990622613579"},"directories":{},"publish_time":1509250350880,"_hasShrinkwrap":false,"_cnpm_publish_time":1509250350880,"_cnpmcore_publish_time":"2021-12-16T19:24:10.055Z"},"1.0.1":{"name":"knuth-shuffle","version":"1.0.1","description":"The Fisher-Yates (aka Knuth) shuffle for Browser and Node.js","main":"index.js","scripts":{"test":"node example.js"},"repository":{"type":"git","url":"git://github.com/coolaj86/knuth-shuffle.git"},"keywords":["ronald","fisher","frank","yates","fisher-yates","donald","knuth","shuffle","random","randomize","unbiased","algorithm"],"author":{"name":"AJ ONeal","email":"coolaj86@gmail.com","url":"http://coolaj86.info/"},"license":"Apache2","bugs":{"url":"https://github.com/coolaj86/knuth-shuffle/issues"},"homepage":"https://github.com/coolaj86/knuth-shuffle","_id":"knuth-shuffle@1.0.1","_shasum":"454940ae816c14e1af6e6f09d8828818f95b5191","_from":"./","_npmVersion":"1.4.9","_npmUser":{"name":"coolaj86","email":"coolaj86@gmail.com"},"maintainers":[{"name":"coolaj86","email":""}],"dist":{"shasum":"454940ae816c14e1af6e6f09d8828818f95b5191","size":5885,"noattachment":false,"key":"/knuth-shuffle/-/knuth-shuffle-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/knuth-shuffle/download/knuth-shuffle-1.0.1.tgz"},"directories":{},"publish_time":1411896147539,"_hasShrinkwrap":false,"_cnpm_publish_time":1411896147539,"_cnpmcore_publish_time":"2021-12-16T19:24:10.427Z"},"1.0.0":{"name":"knuth-shuffle","version":"1.0.0","description":"The Fisher-Yates (aka Knuth) shuffle for Browser and Node.js","main":"index.js","scripts":{"test":"node example.js"},"repository":{"type":"git","url":"git://github.com/coolaj86/knuth-shuffle.git"},"keywords":["ronald","fisher","frank","yates","fisher-yates","donald","knuth","shuffle","random","randomize","unbiased","algorithm"],"author":{"name":"AJ ONeal","email":"coolaj86@gmail.com","url":"http://coolaj86.info/"},"license":"Apache2","bugs":{"url":"https://github.com/coolaj86/knuth-shuffle/issues"},"readmeFilename":"README.md","_id":"knuth-shuffle@1.0.0","dist":{"shasum":"c11341f8c99d10e456a80aec3060bf330a2358e0","size":5789,"noattachment":false,"key":"/knuth-shuffle/-/knuth-shuffle-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/knuth-shuffle/download/knuth-shuffle-1.0.0.tgz"},"_from":"./","_npmVersion":"1.3.11","_npmUser":{"name":"coolaj86","email":"coolaj86@gmail.com"},"maintainers":[{"name":"coolaj86","email":""}],"directories":{},"publish_time":1386057034826,"_hasShrinkwrap":false,"_cnpm_publish_time":1386057034826,"_cnpmcore_publish_time":"2021-12-16T19:24:10.623Z"}},"readme":"knuth-shuffle\n=============\n\nThe Fisher-Yates (aka Knuth) shuffle for Browser and Node.js\n\n  * [Mike Bostock's Fisher–Yates Shuffle Visualization](http://bost.ocks.org/mike/shuffle/)\n  * [How to randomize/shuffle a JavaScript array](http://stackoverflow.com/questions/2450954/how-to-randomize-shuffle-a-javascript-array)\n  * [Fisher-Yates Shuffle on Wikipedia](http://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle)\n  * [Doing the Microsoft Shuffle: Algorithm Fail in Browser Ballot](http://www.robweir.com/blog/2010/02/microsoft-random-browser-ballot.html)\n  * [knuth-shuffle on NPM](https://npmjs.org/package/knuth-shuffle)\n\n'nuf said.\n\nThe Fisher-Yates (Knuth) Shuffle\n===\n\nAs Microsoft learned the hard way (see article below), `function random() { return 0.5 - Math.random() }` turns out to be no-so-random at all.\n\nThe fisher-yates shuffle is an algorithm so simple that even\n[IEEE floating point math](http://blogs.adobe.com/bparadie/2011/11/22/0-2-0-1-0-30000000000000004/)\ncan't screw it up!\n\nI put this on npm as `knuth-shuffle` because `fisher-yates-shuffle`\nwas just too long of a name and shuffle was already taken.\n\nBrowser Example\n===\n\n```html\n<script src=\"https://raw.github.com/coolaj86/knuth-shuffle/master/index.js\"></script>\n```\n\n```javascript\n(function () {\n  'use strict';\n\n  var a = [2,11,37,42];\n  var b;\n\n  // The shuffle modifies the original array\n  // calling a.slice(0) creates a copy, which is assigned to b\n  b = window.knuthShuffle(a.slice(0));\n  console.log(b);\n}());\n```\n\nNode Example\n===\n\nDecentralized Install\n\n```bash\nnpm install --save git+https://git.coolaj86.com/coolaj86/knuth-shuffle.js.git#v1.0\n```\n\nCentralized Install\n\n```bash\nnpm install --save knuth-shuffle@1.0\n```\n\n```javascript\n(function () {\n  'use strict';\n\n  var shuffle = require('knuth-shuffle').knuthShuffle;\n  var a = [2,11,37,42];\n  var b;\n\n  // The shuffle modifies the original array\n  // calling a.slice(0) creates a copy, which is assigned to b\n  b = shuffle(a.slice(0));\n  console.log(b);\n}());\n```\n","_attachments":{},"homepage":"https://git.coolaj86.com/coolaj86/knuth-shuffle.js","bugs":{"url":"https://git.coolaj86.com/coolaj86/knuth-shuffle/issues"},"license":"(MIT OR Apache-2.0)"}