{"_id":"array-shuffle","_rev":"4635333","name":"array-shuffle","description":"Randomize the order of items in an array","dist-tags":{"latest":"4.1.0"},"maintainers":[{"name":"sindresorhus","email":""}],"time":{"modified":"2026-04-10T19:14:42.000Z","created":"2014-05-23T23:05:52.066Z","4.1.0":"2026-02-02T19:38:22.899Z","4.0.0":"2025-09-19T04:13:38.856Z","3.0.0":"2021-07-26T11:54:35.486Z","2.0.0":"2020-12-03T05:02:47.709Z","1.0.1":"2016-06-16T12:13:24.183Z","1.0.0":"2014-08-13T16:36:47.276Z","0.1.0":"2014-05-23T23:05:52.066Z"},"users":{},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"repository":{"type":"git","url":"git+https://github.com/sindresorhus/array-shuffle.git"},"versions":{"4.1.0":{"name":"array-shuffle","version":"4.1.0","description":"Randomize the order of items in an array","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/array-shuffle.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"types":"./index.d.ts","default":"./index.js"},"sideEffects":false,"engines":{"node":">=20"},"scripts":{"test":"xo && ava"},"keywords":["array","list","shuffle","sort","random","rand","fisher","yates","durstenfeld"],"devDependencies":{"ava":"^6.4.1","xo":"^1.2.2"},"gitHead":"7a3bd16755529d8b2caebe357a74d71a7e5f022c","types":"./index.d.ts","_id":"array-shuffle@4.1.0","bugs":{"url":"https://github.com/sindresorhus/array-shuffle/issues"},"homepage":"https://github.com/sindresorhus/array-shuffle#readme","_nodeVersion":"25.3.0","_npmVersion":"11.7.0","dist":{"shasum":"32a967bc99186c3df40c36efdeb2b4dd504d89fa","size":2402,"noattachment":false,"key":"/array-shuffle/-/array-shuffle-4.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/array-shuffle/download/array-shuffle-4.1.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/array-shuffle_4.1.0_1770061102744_0.1322758605929597"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2026-02-02T19:38:22.899Z","publish_time":1770061102899,"_source_registry_name":"default","_cnpm_publish_time":1770061102899},"4.0.0":{"name":"array-shuffle","version":"4.0.0","description":"Randomize the order of items in an array","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/array-shuffle.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"types":"./index.d.ts","default":"./index.js"},"sideEffects":false,"engines":{"node":">=20"},"scripts":{"test":"xo && ava"},"keywords":["array","list","shuffle","sort","random","rand","fisher","yates","durstenfeld"],"devDependencies":{"ava":"^6.4.1","xo":"^1.2.2"},"_id":"array-shuffle@4.0.0","gitHead":"0b7a90367e53e0a427ffd43c923a2f06f7895f1e","types":"./index.d.ts","bugs":{"url":"https://github.com/sindresorhus/array-shuffle/issues"},"homepage":"https://github.com/sindresorhus/array-shuffle#readme","_nodeVersion":"20.19.5","_npmVersion":"10.9.2","dist":{"shasum":"50e2985cb34f8283da13645098ab7a1770cfaa89","size":1995,"noattachment":false,"key":"/array-shuffle/-/array-shuffle-4.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/array-shuffle/download/array-shuffle-4.0.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/array-shuffle_4.0.0_1758255218669_0.8911482476337291"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-09-19T04:13:38.856Z","publish_time":1758255218856,"_source_registry_name":"default","_cnpm_publish_time":1758255218856},"3.0.0":{"name":"array-shuffle","version":"3.0.0","description":"Randomize the order of items in an array","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/array-shuffle.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":"./index.js","engines":{"node":">=12.20"},"scripts":{"test":"xo && ava && tsd"},"keywords":["array","list","shuffle","sort","random","rand","fisher","yates","durstenfeld"],"devDependencies":{"ava":"^3.15.0","tsd":"^0.17.0","xo":"^0.42.0"},"gitHead":"9841c176ad383ed165d7fe32c41de45a946af35a","bugs":{"url":"https://github.com/sindresorhus/array-shuffle/issues"},"homepage":"https://github.com/sindresorhus/array-shuffle#readme","_id":"array-shuffle@3.0.0","_nodeVersion":"12.22.1","_npmVersion":"7.10.0","dist":{"shasum":"9a927cc2ca4c8ef4d71cddef7c9ee7b3b733d54b","size":1718,"noattachment":false,"key":"/array-shuffle/-/array-shuffle-3.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/array-shuffle/download/array-shuffle-3.0.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/array-shuffle_3.0.0_1627300475369_0.9803009004663987"},"_hasShrinkwrap":false,"publish_time":1627300475486,"_cnpm_publish_time":1627300475486,"_cnpmcore_publish_time":"2021-12-16T12:50:22.846Z"},"2.0.0":{"name":"array-shuffle","version":"2.0.0","description":"Randomize the order of items in an array","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/array-shuffle.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"engines":{"node":">=10"},"scripts":{"test":"xo && ava && tsd"},"keywords":["array","list","shuffle","sort","random","rand","fisher","yates","durstenfeld"],"devDependencies":{"ava":"^3.13.0","tsd":"^0.13.1","xo":"^0.35.0"},"gitHead":"c5c93bfb2c68deb04790f33deb1864392ab24be2","bugs":{"url":"https://github.com/sindresorhus/array-shuffle/issues"},"homepage":"https://github.com/sindresorhus/array-shuffle#readme","_id":"array-shuffle@2.0.0","_nodeVersion":"10.22.1","_npmVersion":"6.14.9","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"fd36437cd7997d557055283c946e46379a7cd343","size":1738,"noattachment":false,"key":"/array-shuffle/-/array-shuffle-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/array-shuffle/download/array-shuffle-2.0.0.tgz"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/array-shuffle_2.0.0_1606971767556_0.5324534133108823"},"_hasShrinkwrap":false,"publish_time":1606971767709,"_cnpm_publish_time":1606971767709,"_cnpmcore_publish_time":"2021-12-16T12:50:23.350Z"},"1.0.1":{"name":"array-shuffle","version":"1.0.1","description":"Randomize the order of items in an array","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/array-shuffle.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=0.10.0"},"scripts":{"test":"xo && ava"},"files":["index.js"],"keywords":["array","arr","list","shuffle","sort","random","rand","fisher","yates"],"devDependencies":{"ava":"*","xo":"*"},"gitHead":"4fb28db5732f8e39ae91e7b59b44bd4a189d5fab","bugs":{"url":"https://github.com/sindresorhus/array-shuffle/issues"},"homepage":"https://github.com/sindresorhus/array-shuffle#readme","_id":"array-shuffle@1.0.1","_shasum":"7ea4882a356b4bca5f545e0b6e52eaf6d971557a","_from":".","_npmVersion":"2.15.0","_nodeVersion":"4.4.2","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"7ea4882a356b4bca5f545e0b6e52eaf6d971557a","size":1591,"noattachment":false,"key":"/array-shuffle/-/array-shuffle-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/array-shuffle/download/array-shuffle-1.0.1.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/array-shuffle-1.0.1.tgz_1466079203271_0.5538289665710181"},"directories":{},"publish_time":1466079204183,"_hasShrinkwrap":false,"_cnpm_publish_time":1466079204183,"_cnpmcore_publish_time":"2021-12-16T12:50:23.614Z"},"1.0.0":{"name":"array-shuffle","version":"1.0.0","description":"Randomize the order of items in an array","license":"MIT","repository":{"type":"git","url":"git://github.com/sindresorhus/array-shuffle"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"http://sindresorhus.com"},"engines":{"node":">=0.10.0"},"scripts":{"test":"mocha"},"files":["index.js"],"keywords":["array","arr","list","shuffle","sort","random","rand","fisher","yates"],"devDependencies":{"mocha":"*"},"gitHead":"62c3030d199601c644392dbce3ac822b222d1b4b","bugs":{"url":"https://github.com/sindresorhus/array-shuffle/issues"},"homepage":"https://github.com/sindresorhus/array-shuffle","_id":"array-shuffle@1.0.0","_shasum":"c133fa73587099bd77ad17cb762dd7ee44d9415b","_from":".","_npmVersion":"1.4.14","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"maintainers":[{"name":"sindresorhus","email":""}],"dist":{"shasum":"c133fa73587099bd77ad17cb762dd7ee44d9415b","size":900,"noattachment":false,"key":"/array-shuffle/-/array-shuffle-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/array-shuffle/download/array-shuffle-1.0.0.tgz"},"directories":{},"publish_time":1407947807276,"_hasShrinkwrap":false,"_cnpm_publish_time":1407947807276,"_cnpmcore_publish_time":"2021-12-16T12:50:23.822Z"},"0.1.0":{"name":"array-shuffle","version":"0.1.0","description":"Randomize the order of items in an array","license":"MIT","repository":{"type":"git","url":"git://github.com/sindresorhus/array-shuffle"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"http://sindresorhus.com"},"engines":{"node":">=0.10.0"},"scripts":{"test":"mocha","browser":"browserify -s $npm_package_name -o browser.js ."},"files":["index.js"],"keywords":["array","arr","list","shuffle","sort","random","rand","fisher","yates"],"devDependencies":{"browserify":"*","mocha":"*"},"bugs":{"url":"https://github.com/sindresorhus/array-shuffle/issues"},"homepage":"https://github.com/sindresorhus/array-shuffle","_id":"array-shuffle@0.1.0","_shasum":"228486aba98864241725bb24ae69871824ad4753","_from":".","_npmVersion":"1.4.9","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"maintainers":[{"name":"sindresorhus","email":""}],"dist":{"shasum":"228486aba98864241725bb24ae69871824ad4753","size":960,"noattachment":false,"key":"/array-shuffle/-/array-shuffle-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/array-shuffle/download/array-shuffle-0.1.0.tgz"},"directories":{},"publish_time":1400886352066,"_hasShrinkwrap":false,"_cnpm_publish_time":1400886352066,"_cnpmcore_publish_time":"2021-12-16T12:50:24.109Z"}},"readme":"# array-shuffle\n\n> Randomize the order of items in an array\n\nUses the [Durstenfeld algorithm](https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#The_modern_algorithm) which is based on the [Fisher–Yates algorithm](https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle).\n\n## Install\n\n```sh\nnpm install array-shuffle\n```\n\n## Usage\n\n```js\nimport {arrayToShuffled, arrayShuffle} from 'array-shuffle';\n\n// Create a new shuffled array\nconst shuffled = arrayToShuffled([1, 2, 3, 4, 5, 6]);\n//=> [3, 5, 4, 1, 2, 6]\n\n// Shuffle in-place\nconst array = [1, 2, 3, 4, 5, 6];\narrayShuffle(array);\nconsole.log(array);\n//=> [3, 5, 4, 1, 2, 6]\n```\n\n## API\n\n### arrayToShuffled(array, options?)\n\nCreate a new array with the items randomized (does not mutate the original array).\n\nReturns a new array with the items randomized.\n\n#### array\n\nType: `Array`\n\nThe array to shuffle.\n\n#### options\n\nType: `object`\n\n##### randomNumberGenerator\n\nType: `() => number`\n\nCustom random number generator that returns a float between 0 (inclusive) and 1 (exclusive). This is useful for deterministic shuffling when you use a seeded generator.\n\n```js\nimport {arrayToShuffled} from 'array-shuffle';\n\nconst randomNumberGenerator = () => 0;\nconst deterministic = arrayToShuffled([1, 2, 3, 4, 5, 6], {randomNumberGenerator});\n//=> [2, 3, 4, 5, 6, 1]\n```\n\n### arrayShuffle(array, options?)\n\nRandomize the order of items in an array, mutating the array in-place.\n\nReturns the input array shuffled.\n\n#### array\n\nType: `Array`\n\nThe array to shuffle.\n\n#### options\n\nType: `object`\n\n##### randomNumberGenerator\n\nType: `() => number`\n\nCustom random number generator that returns a float between 0 (inclusive) and 1 (exclusive). This is useful for deterministic shuffling when you use a seeded generator.\n","_attachments":{},"homepage":"https://github.com/sindresorhus/array-shuffle#readme","bugs":{"url":"https://github.com/sindresorhus/array-shuffle/issues"},"license":"MIT"}