{"_id":"pandemonium","_rev":"4240699","name":"pandemonium","description":"Typical random-related functions for JavaScript.","dist-tags":{"latest":"2.4.1"},"maintainers":[{"name":"yomguithereal","email":""}],"time":{"modified":"2026-03-26T00:45:57.000Z","created":"2017-02-28T21:29:49.645Z","2.4.1":"2022-09-20T14:28:16.183Z","2.4.0":"2022-09-14T13:22:21.973Z","2.3.0":"2021-12-08T16:12:25.785Z","2.2.0":"2021-12-01T11:05:23.773Z","2.1.0":"2021-11-21T18:36:07.450Z","2.0.0":"2020-11-21T10:45:34.775Z","1.5.0":"2020-03-24T17:05:45.308Z","1.4.1":"2017-11-09T16:57:03.484Z","1.4.0":"2017-10-03T10:08:57.223Z","1.3.0":"2017-09-11T07:56:08.574Z","1.2.1":"2017-09-05T16:01:33.159Z","1.2.0":"2017-09-05T15:58:54.943Z","1.1.0":"2017-04-20T15:53:36.801Z","1.0.2":"2017-02-28T21:50:03.042Z","1.0.1":"2017-02-28T21:43:14.508Z","1.0.0":"2017-02-28T21:29:49.645Z"},"users":{},"author":{"name":"Guillaume Plique","url":"http://github.com/Yomguithereal"},"repository":{"type":"git","url":"git+https://github.com/yomguithereal/pandemonium.git"},"versions":{"2.4.1":{"name":"pandemonium","version":"2.4.1","description":"Typical random-related functions for JavaScript.","main":"index.js","types":"index.d.ts","scripts":{"lint":"eslint *.js","prepublishOnly":"npm run lint && npm test","prettier":"prettier --write './**/*.js' './**/*.ts' './**/*.md'","test":"mocha && npm run test:types","test:types":"tsc --lib es2015,dom --noEmit --noImplicitAny --noImplicitReturns ./test-types.ts"},"repository":{"type":"git","url":"git+https://github.com/yomguithereal/pandemonium.git"},"keywords":["random","choice","sample","shuffle"],"author":{"name":"Guillaume Plique","url":"http://github.com/Yomguithereal"},"license":"MIT","bugs":{"url":"https://github.com/yomguithereal/pandemonium/issues"},"homepage":"https://github.com/yomguithereal/pandemonium#readme","dependencies":{"mnemonist":"^0.39.2"},"devDependencies":{"@yomguithereal/eslint-config":"^4.4.0","@yomguithereal/prettier-config":"^1.2.0","eslint":"^8.23.0","eslint-config-prettier":"^8.5.0","mocha":"^9.2.2","prettier":"^2.7.1","seedrandom":"^3.0.5","typescript":"^4.8.2"},"prettier":"@yomguithereal/prettier-config","eslintConfig":{"extends":["@yomguithereal/eslint-config","eslint-config-prettier"]},"gitHead":"7eb5eabf1fcbe5d09c8a81941ce548d7cdbf1f6a","_id":"pandemonium@2.4.1","_nodeVersion":"14.19.0","_npmVersion":"8.19.2","dist":{"shasum":"bd51ca72184c6ae135f9049a33c8605bfdb9574d","size":20459,"noattachment":false,"key":"/pandemonium/-/pandemonium-2.4.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/pandemonium/download/pandemonium-2.4.1.tgz"},"_npmUser":{"name":"yomguithereal","email":"kropotkinepiotr@gmail.com"},"directories":{},"maintainers":[{"name":"yomguithereal","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/pandemonium_2.4.1_1663684096016_0.22728319199822034"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-09-20T15:11:25.428Z","publish_time":1663684096183,"_cnpm_publish_time":1663684096183},"2.4.0":{"name":"pandemonium","version":"2.4.0","description":"Typical random-related functions for JavaScript.","main":"index.js","types":"index.d.ts","scripts":{"lint":"eslint *.js","prepublishOnly":"npm run lint && npm test","prettier":"prettier --write './**/*.js' './**/*.ts' './**/*.md'","test":"mocha && npm run test:types","test:types":"tsc --lib es2015,dom --noEmit --noImplicitAny --noImplicitReturns ./test-types.ts"},"repository":{"type":"git","url":"git+https://github.com/yomguithereal/pandemonium.git"},"keywords":["random","choice","sample","shuffle"],"author":{"name":"Guillaume Plique","url":"http://github.com/Yomguithereal"},"license":"MIT","bugs":{"url":"https://github.com/yomguithereal/pandemonium/issues"},"homepage":"https://github.com/yomguithereal/pandemonium#readme","dependencies":{"mnemonist":"^0.39.2"},"devDependencies":{"@yomguithereal/eslint-config":"^4.4.0","@yomguithereal/prettier-config":"^1.2.0","eslint":"^8.23.0","eslint-config-prettier":"^8.5.0","mocha":"^9.2.2","prettier":"^2.7.1","seedrandom":"^3.0.5","typescript":"^4.8.2"},"prettier":"@yomguithereal/prettier-config","eslintConfig":{"extends":["@yomguithereal/eslint-config","eslint-config-prettier"]},"gitHead":"0e180a9b0d638d4b53a9711dc25a3ea10d90c0df","_id":"pandemonium@2.4.0","_nodeVersion":"14.19.0","_npmVersion":"8.5.2","dist":{"shasum":"9466c8d6c3f6fe332bf15307d5c9a82bd9230b0e","size":20463,"noattachment":false,"key":"/pandemonium/-/pandemonium-2.4.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/pandemonium/download/pandemonium-2.4.0.tgz"},"_npmUser":{"name":"yomguithereal","email":"kropotkinepiotr@gmail.com"},"directories":{},"maintainers":[{"name":"yomguithereal","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/pandemonium_2.4.0_1663161741791_0.11265303468251497"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-09-14T14:09:20.532Z","publish_time":1663161741973,"_cnpm_publish_time":1663161741973},"2.3.0":{"name":"pandemonium","version":"2.3.0","description":"Typical random-related functions for JavaScript.","main":"index.js","types":"index.d.ts","scripts":{"lint":"eslint *.js","prepublishOnly":"npm run lint && npm test","prettier":"prettier --write './**/*.js' './**/*.ts' './**/*.md'","test":"mocha && npm run test:types","test:types":"tsc --lib es2015,dom --noEmit --noImplicitAny --noImplicitReturns ./test-types.ts"},"repository":{"type":"git","url":"git+https://github.com/yomguithereal/pandemonium.git"},"keywords":["random","choice","sample","shuffle"],"author":{"name":"Guillaume Plique","url":"http://github.com/Yomguithereal"},"license":"MIT","bugs":{"url":"https://github.com/yomguithereal/pandemonium/issues"},"homepage":"https://github.com/yomguithereal/pandemonium#readme","dependencies":{"mnemonist":"^0.39.0"},"devDependencies":{"@yomguithereal/eslint-config":"^4.4.0","@yomguithereal/prettier-config":"^1.2.0","eslint":"^8.4.1","eslint-config-prettier":"^8.3.0","mocha":"^9.1.3","prettier":"^2.5.1","seedrandom":"^3.0.5","typescript":"^4.5.2"},"prettier":"@yomguithereal/prettier-config","eslintConfig":{"extends":["@yomguithereal/eslint-config","eslint-config-prettier"]},"gitHead":"9497bea7d95a137c544a63765ccf943f624befe7","_id":"pandemonium@2.3.0","_nodeVersion":"12.22.6","_npmVersion":"7.24.2","dist":{"shasum":"d9c70686bb33c3ee4f435162601b0755a439bdcb","size":19249,"noattachment":false,"key":"/pandemonium/-/pandemonium-2.3.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/pandemonium/download/pandemonium-2.3.0.tgz"},"_npmUser":{"name":"yomguithereal","email":"kropotkinepiotr@gmail.com"},"directories":{},"maintainers":[{"name":"yomguithereal","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/pandemonium_2.3.0_1638979945657_0.9379648746829456"},"_hasShrinkwrap":false,"publish_time":1638979945785,"_cnpm_publish_time":1638979945785,"_cnpmcore_publish_time":"2021-12-16T15:36:07.435Z"},"2.2.0":{"name":"pandemonium","version":"2.2.0","description":"Typical random-related functions for JavaScript.","main":"index.js","types":"index.d.ts","scripts":{"lint":"eslint *.js","prepublishOnly":"npm run lint && npm test","prettier":"prettier --write './**/*.js' './**/*.ts' './**/*.md'","test":"mocha && npm run test:types","test:types":"tsc --lib es2015,dom --noEmit --noImplicitAny --noImplicitReturns ./test-types.ts"},"repository":{"type":"git","url":"git+https://github.com/yomguithereal/pandemonium.git"},"keywords":["random","choice","sample","shuffle"],"author":{"name":"Guillaume Plique","url":"http://github.com/Yomguithereal"},"license":"MIT","bugs":{"url":"https://github.com/yomguithereal/pandemonium/issues"},"homepage":"https://github.com/yomguithereal/pandemonium#readme","devDependencies":{"@yomguithereal/eslint-config":"^4.4.0","@yomguithereal/prettier-config":"^1.2.0","eslint":"^8.3.0","eslint-config-prettier":"^8.3.0","mnemonist":"^0.39.0","mocha":"^9.1.3","prettier":"^2.4.1","seedrandom":"^3.0.5","typescript":"^4.5.2"},"prettier":"@yomguithereal/prettier-config","eslintConfig":{"extends":["@yomguithereal/eslint-config","eslint-config-prettier"]},"gitHead":"0b5f71863a2fc1e48174de526f58f5eefb7838bc","_id":"pandemonium@2.2.0","_nodeVersion":"12.22.7","_npmVersion":"8.1.0","dist":{"shasum":"77e051d97dab9d480525f64f8f0a0ec673f57ba7","size":16273,"noattachment":false,"key":"/pandemonium/-/pandemonium-2.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/pandemonium/download/pandemonium-2.2.0.tgz"},"_npmUser":{"name":"yomguithereal","email":"kropotkinepiotr@gmail.com"},"directories":{},"maintainers":[{"name":"yomguithereal","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/pandemonium_2.2.0_1638356723623_0.25389618692761684"},"_hasShrinkwrap":false,"publish_time":1638356723773,"_cnpm_publish_time":1638356723773,"_cnpmcore_publish_time":"2021-12-16T15:36:07.653Z"},"2.1.0":{"name":"pandemonium","version":"2.1.0","description":"Typical random-related functions for JavaScript.","main":"index.js","types":"index.d.ts","scripts":{"lint":"eslint *.js","prepublishOnly":"npm run lint && npm test","prettier":"prettier --write './**/*.js' './**/*.ts' './**/*.md'","test":"mocha && npm run test:types","test:types":"tsc --lib es2015,dom --noEmit --noImplicitAny --noImplicitReturns ./test-types.ts"},"repository":{"type":"git","url":"git+https://github.com/yomguithereal/pandemonium.git"},"keywords":["random","choice","sample","shuffle"],"author":{"name":"Guillaume Plique","url":"http://github.com/Yomguithereal"},"license":"MIT","bugs":{"url":"https://github.com/yomguithereal/pandemonium/issues"},"homepage":"https://github.com/yomguithereal/pandemonium#readme","devDependencies":{"@yomguithereal/eslint-config":"^4.4.0","@yomguithereal/prettier-config":"^1.2.0","eslint":"^8.3.0","eslint-config-prettier":"^8.3.0","mocha":"^9.1.3","prettier":"^2.4.1","seedrandom":"^3.0.5","typescript":"^4.5.2"},"prettier":"@yomguithereal/prettier-config","eslintConfig":{"extends":["@yomguithereal/eslint-config","eslint-config-prettier"]},"gitHead":"8745fab0679fb44d09e2913b91cc82514c33feae","_id":"pandemonium@2.1.0","_nodeVersion":"12.22.7","_npmVersion":"8.1.0","dist":{"shasum":"f3dee8faf1b9b85fcec039fc470547b3f9fecc7c","size":14168,"noattachment":false,"key":"/pandemonium/-/pandemonium-2.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/pandemonium/download/pandemonium-2.1.0.tgz"},"_npmUser":{"name":"yomguithereal","email":"kropotkinepiotr@gmail.com"},"directories":{},"maintainers":[{"name":"yomguithereal","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/pandemonium_2.1.0_1637519767341_0.3150548659983492"},"_hasShrinkwrap":false,"publish_time":1637519767450,"_cnpm_publish_time":1637519767450,"_cnpmcore_publish_time":"2021-12-16T15:36:07.919Z"},"2.0.0":{"name":"pandemonium","version":"2.0.0","description":"Typical random-related functions for JavaScript.","main":"index.js","scripts":{"lint":"eslint *.js","prepublish":"npm run lint && npm test","test":"mocha && npm run test:types","test:types":"tsc --lib es2015,dom --noEmit --noImplicitAny --noImplicitReturns ./test-types.ts"},"repository":{"type":"git","url":"git+https://github.com/yomguithereal/pandemonium.git"},"keywords":["random","choice","sample","shuffle"],"author":{"name":"Guillaume Plique","url":"http://github.com/Yomguithereal"},"license":"MIT","bugs":{"url":"https://github.com/yomguithereal/pandemonium/issues"},"homepage":"https://github.com/yomguithereal/pandemonium#readme","devDependencies":{"@yomguithereal/eslint-config":"^4.0.0","eslint":"^7.13.0","mocha":"^8.2.1","seedrandom":"^3.0.5","typescript":"^4.1.2"},"eslintConfig":{"extends":"@yomguithereal/eslint-config","globals":{"Set":true}},"gitHead":"c369982305f63a3ebc7ed0a1a8223469189c355c","_id":"pandemonium@2.0.0","_nodeVersion":"12.19.0","_npmVersion":"6.14.8","_npmUser":{"name":"yomguithereal","email":"kropotkinepiotr@gmail.com"},"dist":{"shasum":"4b0a646a4372e651ab7ab18f5277dbedc197ecd1","size":12421,"noattachment":false,"key":"/pandemonium/-/pandemonium-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/pandemonium/download/pandemonium-2.0.0.tgz"},"directories":{},"maintainers":[{"name":"yomguithereal","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/pandemonium_2.0.0_1605955534618_0.9002739230060011"},"_hasShrinkwrap":false,"publish_time":1605955534775,"_cnpm_publish_time":1605955534775,"_cnpmcore_publish_time":"2021-12-16T15:36:08.219Z"},"1.5.0":{"name":"pandemonium","version":"1.5.0","description":"Typical random-related functions for JavaScript.","main":"index.js","scripts":{"lint":"eslint *.js","prepublish":"npm run lint && npm test","test":"mocha && npm run test:types","test:types":"tsc --lib es2015,dom --noEmit --noImplicitAny --noImplicitReturns ./test-types.ts"},"repository":{"type":"git","url":"git+https://github.com/yomguithereal/pandemonium.git"},"keywords":["random","choice","sample","shuffle"],"author":{"name":"Guillaume Plique","url":"http://github.com/Yomguithereal"},"license":"MIT","bugs":{"url":"https://github.com/yomguithereal/pandemonium/issues"},"homepage":"https://github.com/yomguithereal/pandemonium#readme","devDependencies":{"@yomguithereal/eslint-config":"^4.0.0","eslint":"^6.8.0","mocha":"^7.1.1","seedrandom":"^3.0.5","typescript":"^3.8.3"},"eslintConfig":{"extends":"@yomguithereal/eslint-config","globals":{"Set":true}},"gitHead":"5a6a9a4594fbd2ecfcb2bc5f4c8d401ea430fb6b","_id":"pandemonium@1.5.0","_nodeVersion":"10.13.0","_npmVersion":"6.14.3","_npmUser":{"name":"yomguithereal","email":"kropotkinepiotr@gmail.com"},"dist":{"shasum":"93f35af555de1420022b341e730215c51c725be3","size":8353,"noattachment":false,"key":"/pandemonium/-/pandemonium-1.5.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/pandemonium/download/pandemonium-1.5.0.tgz"},"maintainers":[{"name":"yomguithereal","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/pandemonium_1.5.0_1585069545140_0.8612851438431284"},"_hasShrinkwrap":false,"publish_time":1585069545308,"_cnpm_publish_time":1585069545308,"_cnpmcore_publish_time":"2021-12-16T15:36:08.436Z"},"1.4.1":{"name":"pandemonium","version":"1.4.1","description":"Typical random-related functions for JavaScript.","main":"index.js","scripts":{"lint":"eslint *.js","prepublish":"npm run lint && npm test","test":"mocha"},"files":["choice.js","dangerous-but-performant-sample.js","index.js","naive-sample.js","random-index.js","random-string.js","random.js","sample.js","sample-with-replacements.js","shuffle-in-place.js","shuffle.js","weighted-choice.js","weighted-random-index.js"],"repository":{"type":"git","url":"git+https://github.com/yomguithereal/pandemonium.git"},"keywords":["random","choice","sample","shuffle"],"author":{"name":"Guillaume Plique","url":"http://github.com/Yomguithereal"},"license":"MIT","bugs":{"url":"https://github.com/yomguithereal/pandemonium/issues"},"homepage":"https://github.com/yomguithereal/pandemonium#readme","devDependencies":{"@yomguithereal/eslint-config":"^4.0.0","eslint":"^4.10.0","mocha":"^4.0.1","seedrandom":"^2.4.2"},"eslintConfig":{"extends":"@yomguithereal/eslint-config","globals":{"Set":true}},"gitHead":"3dc871bd781dc0171fdef9a2ada4f74fb4d3afad","_id":"pandemonium@1.4.1","_npmVersion":"5.5.1","_nodeVersion":"9.1.0","_npmUser":{"name":"yomguithereal","email":"kropotkinepiotr@gmail.com"},"maintainers":[{"name":"yomguithereal","email":""}],"dist":{"shasum":"61f4fb0df843a9282b5f7bce7a467ed05857961d","size":7221,"noattachment":false,"key":"/pandemonium/-/pandemonium-1.4.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/pandemonium/download/pandemonium-1.4.1.tgz"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/pandemonium-1.4.1.tgz_1510246622965_0.12385196820832789"},"directories":{},"publish_time":1510246623484,"_hasShrinkwrap":false,"_cnpm_publish_time":1510246623484,"_cnpmcore_publish_time":"2021-12-16T15:36:08.635Z"},"1.4.0":{"name":"pandemonium","version":"1.4.0","description":"Typical random-related functions for JavaScript.","main":"index.js","scripts":{"lint":"eslint *.js","prepublish":"npm run lint && npm test","test":"mocha"},"files":["choice.js","dangerous-but-performant-sample.js","index.js","naive-sample.js","random-index.js","random-string.js","random.js","sample.js","sample-with-replacements.js","shuffle-in-place.js","shuffle.js","weighted-choice.js","weighted-random-index.js"],"repository":{"type":"git","url":"git+https://github.com/yomguithereal/pandemonium.git"},"keywords":["random","choice","sample","shuffle"],"author":{"name":"Guillaume Plique","url":"http://github.com/Yomguithereal"},"license":"MIT","bugs":{"url":"https://github.com/yomguithereal/pandemonium/issues"},"homepage":"https://github.com/yomguithereal/pandemonium#readme","devDependencies":{"@yomguithereal/eslint-config":"^3.0.0","eslint":"^3.16.1","mocha":"^3.2.0","seedrandom":"^2.4.2"},"eslintConfig":{"extends":"@yomguithereal/eslint-config","globals":{"Set":true}},"gitHead":"967d92d4c7e6613d9da8102440d705926da2986c","_id":"pandemonium@1.4.0","_npmVersion":"5.4.2","_nodeVersion":"8.6.0","_npmUser":{"name":"yomguithereal","email":"kropotkinepiotr@gmail.com"},"maintainers":[{"name":"yomguithereal","email":""}],"dist":{"shasum":"8ccfbe6b3ba4b4e740c726eeae7215bb6e1e472c","size":7217,"noattachment":false,"key":"/pandemonium/-/pandemonium-1.4.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/pandemonium/download/pandemonium-1.4.0.tgz"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/pandemonium-1.4.0.tgz_1507025336198_0.6018554226029664"},"directories":{},"publish_time":1507025337223,"_hasShrinkwrap":false,"_cnpm_publish_time":1507025337223,"_cnpmcore_publish_time":"2021-12-16T15:36:08.818Z"},"1.3.0":{"name":"pandemonium","version":"1.3.0","description":"Typical random-related functions for JavaScript.","main":"index.js","scripts":{"lint":"eslint *.js","prepublish":"npm run lint && npm test","test":"mocha"},"files":["choice.js","dangerous-but-performant-sample.js","index.js","naive-sample.js","random-index.js","random-string.js","random.js","sample.js","shuffle-in-place.js","shuffle.js","weighted-choice.js","weighted-random-index.js"],"repository":{"type":"git","url":"git+https://github.com/yomguithereal/pandemonium.git"},"keywords":["random","choice","sample","shuffle"],"author":{"name":"Guillaume Plique","url":"http://github.com/Yomguithereal"},"license":"MIT","bugs":{"url":"https://github.com/yomguithereal/pandemonium/issues"},"homepage":"https://github.com/yomguithereal/pandemonium#readme","devDependencies":{"@yomguithereal/eslint-config":"^3.0.0","eslint":"^3.16.1","mocha":"^3.2.0","seedrandom":"^2.4.2"},"eslintConfig":{"extends":"@yomguithereal/eslint-config","globals":{"Set":true}},"gitHead":"8c52d25961ae8296d09baf81b1c7b846d8a5a3e4","_id":"pandemonium@1.3.0","_npmVersion":"5.4.1","_nodeVersion":"8.4.0","_npmUser":{"name":"yomguithereal","email":"kropotkinepiotr@gmail.com"},"maintainers":[{"name":"yomguithereal","email":""}],"dist":{"shasum":"9df9be613c9d16c0fc6d63df8fb7a83c1343e1e7","size":6869,"noattachment":false,"key":"/pandemonium/-/pandemonium-1.3.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/pandemonium/download/pandemonium-1.3.0.tgz"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/pandemonium-1.3.0.tgz_1505116567300_0.421356932958588"},"directories":{},"publish_time":1505116568574,"_hasShrinkwrap":false,"_cnpm_publish_time":1505116568574,"_cnpmcore_publish_time":"2021-12-16T15:36:09.031Z"},"1.2.1":{"name":"pandemonium","version":"1.2.1","description":"Typical random-related functions for JavaScript.","main":"index.js","scripts":{"lint":"eslint *.js","prepublish":"npm run lint && npm test","test":"mocha"},"files":["choice.js","dangerous-but-performant-sample.js","index.js","naive-sample.js","random-index.js","random-string.js","random.js","sample.js","shuffle-in-place.js","shuffle.js","weighted-choice.js","weighted-random-index.js"],"repository":{"type":"git","url":"git+https://github.com/yomguithereal/pandemonium.git"},"keywords":["random","choice","sample","shuffle"],"author":{"name":"Guillaume Plique","url":"http://github.com/Yomguithereal"},"license":"MIT","bugs":{"url":"https://github.com/yomguithereal/pandemonium/issues"},"homepage":"https://github.com/yomguithereal/pandemonium#readme","devDependencies":{"@yomguithereal/eslint-config":"^3.0.0","eslint":"^3.16.1","mocha":"^3.2.0","seedrandom":"^2.4.2"},"eslintConfig":{"extends":"@yomguithereal/eslint-config","globals":{"Set":true}},"gitHead":"59b8bdd592dc294ec6e637ac02d18cc9300057a8","_id":"pandemonium@1.2.1","_npmVersion":"5.4.0","_nodeVersion":"8.4.0","_npmUser":{"name":"yomguithereal","email":"kropotkinepiotr@gmail.com"},"maintainers":[{"name":"yomguithereal","email":""}],"dist":{"shasum":"ca3c8d72f5b9ed8cbcc7fb8e0405913eb9aae0c6","size":6720,"noattachment":false,"key":"/pandemonium/-/pandemonium-1.2.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/pandemonium/download/pandemonium-1.2.1.tgz"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/pandemonium-1.2.1.tgz_1504627292113_0.051083495607599616"},"directories":{},"publish_time":1504627293159,"_hasShrinkwrap":false,"_cnpm_publish_time":1504627293159,"_cnpmcore_publish_time":"2021-12-16T15:36:09.281Z"},"1.2.0":{"name":"pandemonium","version":"1.2.0","description":"Typical random-related functions for JavaScript.","main":"index.js","scripts":{"lint":"eslint *.js","prepublish":"npm run lint && npm test","test":"mocha"},"files":["choice.js","dangerous-but-performant-sample.js","index.js","naive-sample.js","random-index.js","random.js","sample.js","shuffle-in-place.js","shuffle.js","weighted-choice.js","weighted-random-index.js"],"repository":{"type":"git","url":"git+https://github.com/yomguithereal/pandemonium.git"},"keywords":["random","choice","sample","shuffle"],"author":{"name":"Guillaume Plique","url":"http://github.com/Yomguithereal"},"license":"MIT","bugs":{"url":"https://github.com/yomguithereal/pandemonium/issues"},"homepage":"https://github.com/yomguithereal/pandemonium#readme","devDependencies":{"@yomguithereal/eslint-config":"^3.0.0","eslint":"^3.16.1","mocha":"^3.2.0","seedrandom":"^2.4.2"},"eslintConfig":{"extends":"@yomguithereal/eslint-config","globals":{"Set":true}},"gitHead":"bf3864d03e3aa7254de357c5ec00a8302e47402e","_id":"pandemonium@1.2.0","_npmVersion":"5.4.0","_nodeVersion":"8.4.0","_npmUser":{"name":"yomguithereal","email":"kropotkinepiotr@gmail.com"},"maintainers":[{"name":"yomguithereal","email":""}],"dist":{"shasum":"062d0ba7288507fc85c5638b81521cba05f3182e","size":6288,"noattachment":false,"key":"/pandemonium/-/pandemonium-1.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/pandemonium/download/pandemonium-1.2.0.tgz"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/pandemonium-1.2.0.tgz_1504627133764_0.745852978201583"},"directories":{},"publish_time":1504627134943,"_hasShrinkwrap":false,"_cnpm_publish_time":1504627134943,"_cnpmcore_publish_time":"2021-12-16T15:36:09.563Z"},"1.1.0":{"name":"pandemonium","version":"1.1.0","description":"Typical random-related functions for JavaScript.","main":"index.js","scripts":{"lint":"eslint *.js","prepublish":"npm run lint && npm test","test":"mocha"},"files":["choice.js","dangerous-but-performant-sample.js","index.js","naive-sample.js","random-index.js","random.js","sample.js","shuffle-in-place.js","shuffle.js","weighted-choice.js","weighted-random-index.js"],"repository":{"type":"git","url":"git+https://github.com/yomguithereal/pandemonium.git"},"keywords":["random","choice","sample","shuffle"],"author":{"name":"Guillaume Plique","url":"http://github.com/Yomguithereal"},"license":"MIT","bugs":{"url":"https://github.com/yomguithereal/pandemonium/issues"},"homepage":"https://github.com/yomguithereal/pandemonium#readme","devDependencies":{"@yomguithereal/eslint-config":"^3.0.0","eslint":"^3.16.1","mocha":"^3.2.0","seedrandom":"^2.4.2"},"eslintConfig":{"extends":"@yomguithereal/eslint-config","globals":{"Set":true}},"gitHead":"05d854223b3738f8990e87d097b4c8f2eee5ff4f","_id":"pandemonium@1.1.0","_shasum":"bb48b8e424623f7ef5a639ff1e52baeed651f241","_from":".","_npmVersion":"4.2.0","_nodeVersion":"7.9.0","_npmUser":{"name":"yomguithereal","email":"kropotkinepiotr@gmail.com"},"maintainers":[{"name":"yomguithereal","email":""}],"dist":{"shasum":"bb48b8e424623f7ef5a639ff1e52baeed651f241","size":6169,"noattachment":false,"key":"/pandemonium/-/pandemonium-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/pandemonium/download/pandemonium-1.1.0.tgz"},"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/pandemonium-1.1.0.tgz_1492703614913_0.7444042430724949"},"directories":{},"publish_time":1492703616801,"_hasShrinkwrap":false,"_cnpm_publish_time":1492703616801,"_cnpmcore_publish_time":"2021-12-16T15:36:09.810Z"},"1.0.2":{"name":"pandemonium","version":"1.0.2","description":"Typical random-related functions for JavaScript.","main":"index.js","scripts":{"lint":"eslint *.js","prepublish":"npm run lint && npm test","test":"mocha"},"files":["choice.js","dangerous-but-performant-sample.js","index.js","naive-sample.js","random-index.js","random.js","sample.js","shuffle-in-place.js","shuffle.js"],"repository":{"type":"git","url":"git+https://github.com/yomguithereal/pandemonium.git"},"keywords":["random","choice","sample","shuffle"],"author":{"name":"Guillaume Plique","url":"http://github.com/Yomguithereal"},"license":"MIT","bugs":{"url":"https://github.com/yomguithereal/pandemonium/issues"},"homepage":"https://github.com/yomguithereal/pandemonium#readme","devDependencies":{"@yomguithereal/eslint-config":"^3.0.0","eslint":"^3.16.1","seedrandom":"^2.4.2"},"eslintConfig":{"extends":"@yomguithereal/eslint-config","globals":{"Set":true}},"gitHead":"f1028e9dedc6f966101b9b8f4048da7e4e6306f3","_id":"pandemonium@1.0.2","_shasum":"38a6390944fe42ffb437a32347f8717d612e6c0c","_from":".","_npmVersion":"4.1.2","_nodeVersion":"7.6.0","_npmUser":{"name":"yomguithereal","email":"kropotkinepiotr@gmail.com"},"maintainers":[{"name":"yomguithereal","email":""}],"dist":{"shasum":"38a6390944fe42ffb437a32347f8717d612e6c0c","size":4534,"noattachment":false,"key":"/pandemonium/-/pandemonium-1.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/pandemonium/download/pandemonium-1.0.2.tgz"},"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/pandemonium-1.0.2.tgz_1488318602440_0.8316068667918444"},"directories":{},"publish_time":1488318603042,"_hasShrinkwrap":false,"_cnpm_publish_time":1488318603042,"_cnpmcore_publish_time":"2021-12-16T15:36:10.008Z"},"1.0.1":{"name":"pandemonium","version":"1.0.1","description":"Typical random-related functions for JavaScript.","main":"index.js","scripts":{"lint":"eslint *.js","prepublish":"npm run lint && npm test","test":"mocha"},"files":["choice.js","dangerous-but-performant-sample.js","index.js","naive-sample.js","random-index.js","random.js","sample.js","shuffle-in-place.js","shuffle.js"],"repository":{"type":"git","url":"git+https://github.com/yomguithereal/pandemonium.git"},"keywords":["random","choice","sample","shuffle"],"author":{"name":"Guillaume Plique","url":"http://github.com/Yomguithereal"},"license":"MIT","bugs":{"url":"https://github.com/yomguithereal/pandemonium/issues"},"homepage":"https://github.com/yomguithereal/pandemonium#readme","devDependencies":{"@yomguithereal/eslint-config":"^3.0.0","eslint":"^3.16.1","seedrandom":"^2.4.2"},"eslintConfig":{"extends":"@yomguithereal/eslint-config","globals":{"Set":true}},"gitHead":"ddc3ac26d33e2246397005fc5a18cd1f8c4e967c","_id":"pandemonium@1.0.1","_shasum":"fa1776733ace96d54f71b340dfb9a3f85bd3f4e5","_from":".","_npmVersion":"4.1.2","_nodeVersion":"7.6.0","_npmUser":{"name":"yomguithereal","email":"kropotkinepiotr@gmail.com"},"maintainers":[{"name":"yomguithereal","email":""}],"dist":{"shasum":"fa1776733ace96d54f71b340dfb9a3f85bd3f4e5","size":4535,"noattachment":false,"key":"/pandemonium/-/pandemonium-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/pandemonium/download/pandemonium-1.0.1.tgz"},"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/pandemonium-1.0.1.tgz_1488318193870_0.9034396938513964"},"directories":{},"publish_time":1488318194508,"_hasShrinkwrap":false,"_cnpm_publish_time":1488318194508,"_cnpmcore_publish_time":"2021-12-16T15:36:10.250Z"},"1.0.0":{"name":"pandemonium","version":"1.0.0","description":"Typical random-related functions for JavaScript.","main":"index.js","scripts":{"lint":"eslint *.js","prepublish":"npm run lint && npm test","test":"mocha"},"files":["choice.js","dangerous-but-performant-sample","index.js","naive-sample.js","random-index.js","random.js","sample.js","shuffle-in-place.js","shuffle.js"],"repository":{"type":"git","url":"git+https://github.com/yomguithereal/pandemonium.git"},"keywords":["random","choice","sample","shuffle"],"author":{"name":"Guillaume Plique","url":"http://github.com/Yomguithereal"},"license":"MIT","bugs":{"url":"https://github.com/yomguithereal/pandemonium/issues"},"homepage":"https://github.com/yomguithereal/pandemonium#readme","devDependencies":{"@yomguithereal/eslint-config":"^3.0.0","eslint":"^3.16.1","seedrandom":"^2.4.2"},"eslintConfig":{"extends":"@yomguithereal/eslint-config","globals":{"Set":true}},"gitHead":"8149cd839559408fbcf685b7d6539c6bee3b040f","_id":"pandemonium@1.0.0","_shasum":"8514ba9084d83d3ee62c994539670f5c44168546","_from":".","_npmVersion":"2.15.11","_nodeVersion":"4.7.2","_npmUser":{"name":"yomguithereal","email":"kropotkinepiotr@gmail.com"},"maintainers":[{"name":"yomguithereal","email":""}],"dist":{"shasum":"8514ba9084d83d3ee62c994539670f5c44168546","size":4267,"noattachment":false,"key":"/pandemonium/-/pandemonium-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/pandemonium/download/pandemonium-1.0.0.tgz"},"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/pandemonium-1.0.0.tgz_1488317389023_0.9685337750706822"},"directories":{},"publish_time":1488317389645,"_hasShrinkwrap":false,"_cnpm_publish_time":1488317389645,"_cnpmcore_publish_time":"2021-12-16T15:36:10.512Z"}},"readme":"[![Build Status](https://github.com/Yomguithereal/pandemonium/workflows/Tests/badge.svg)](https://github.com/Yomguithereal/pandemonium/actions)\n\n# Pandemonium\n\nPandemonium is a dead simple JavaScript/TypeScript library providing typical random-related functions such as `choice`, `sample` etc.\n\nThe library also provides a way to create any of the available functions using a custom random source ([seedrandom](https://www.npmjs.com/package/seedrandom), for instance).\n\n# Installation\n\n```\nnpm install --save pandemonium\n```\n\n# Usage\n\n## Summary\n\n_Typical helpers_\n\n- [choice](#choice)\n- [random](#random)\n- [randomBoolean](#randomboolean)\n- [randomFloat](#randomfloat)\n- [randomIndex](#randomindex)\n- [randomString](#randomstring)\n- [randomUint32](#randomuint32)\n- [randomPair](#randompair)\n- [randomOrderedPair](#randomorderedpair)\n- [shuffle](#shuffle)\n- [shuffleInPlace](#shuffleinplace)\n- [weightedChoice](#weightedchoice)\n- [weightedRandomIndex](#weightedrandomindex)\n\n_Sampling_\n\n`n` being the number of items in the sampled sequence and `k` being the number of items to be sampled.\n\n| Method                                                  | Time            | Memory | Note                                                                        |\n| ------------------------------------------------------- | --------------- | ------ | --------------------------------------------------------------------------- |\n| [dangerouslyMutatingSample](#dangerouslymutatingsample) | `O(k)`          | `O(k)` | Must be able to mutate given array to work.                                 |\n| [fisherYatesSample](#fisheryatessample)                 | `O(n)`          | `O(n)` | Probably not a good idea.                                                   |\n| [geometricReservoirSample](#geometricreservoirsample)   | `O(k*log(n/k))` | `O(k)` | Probably the best way of sampling from a random access data structure.      |\n| [naiveSample](#naivesample)                             | `Ω(k)`, `O(∞)`  | `O(k)` | Only useful if `k << n`.                                                    |\n| [reservoirSample](#reservoirsample)                     | `O(n)`          | `O(k)` | Useful if pulling a sample from a stream.                                   |\n| [sampleWithReplacements](#samplewithreplacements)       | `O(k)`          | `O(k)` | Performant but allows replacements.                                         |\n| [samplePairs](#samplepairs)                             | `Ω(k)`, `O(∞)`  | `O(k)` | Variant of [naiveSample](#naivesample) for unordered pairs.                 |\n| [sampleOrderedPairs](#sampleorderedpairs)               | `Ω(k)`, `O(∞)`  | `O(k)` | Variant of [naiveSample](#naivesample) for ordered pairs.                   |\n| [weightedReservoirSample](#weightedreservoirsample)     | `O(n)`          | `O(k)` | Variant of [reservoirSample](#reservoirsample) working with weighted items. |\n\n## choice\n\nFunction returning a random item from the given array.\n\n```js\nimport choice from 'pandemonium/choice';\n// Or\nimport {choice} from 'pandemonium';\n\nchoice(['apple', 'orange', 'pear']);\n>>> 'orange'\n\n// To create your own function using custom RNG\nimport {createChoice} from 'pandemonium/choice';\n\nconst customChoice = createChoice(rng);\n```\n\n## random\n\nFunction returning a random integer between given `a` & `b`.\n\n```js\nimport random from 'pandemonium/random';\n// Or\nimport {random} from 'pandemonium';\n\nrandom(3, 7);\n>>> 4\n\n// To create your own function using custom RNG\nimport {createRandom} from 'pandemonium/random';\n\nconst customRandom = createRandom(rng);\n```\n\n## randomBoolean\n\nFunction returning a random boolean.\n\n```js\nimport randomBoolean from 'pandemonium/random-boolean';\n// Or\nimport {randomBoolean} from 'pandemonium';\n\nrandomBoolean();\n>>> true\n\n// To create your own function using custom RNG\nimport {createrandomBoolean} from 'pandemonium/random-boolean';\n\nconst customRandomBoolean = createRandomBoolean(rng);\n```\n\n## randomFloat\n\nFunction returning a random float between given `a` & `b`.\n\n```js\nimport randomFloat from 'pandemonium/random-float';\n// Or\nimport {randomFloat} from 'pandemonium';\n\nrandomFloat(-5, 55);\n>>> 6.756482\n\n// To create your own function using custom RNG\nimport {createRandomFloat} from 'pandemonium/random-float';\n\nconst customRandomFloat = createRandomFloat(rng);\n```\n\n## randomIndex\n\nFunction returning a random index of the given array.\n\n```js\nimport randomIndex from 'pandemonium/random-index';\n// Or\nimport {randomIndex} from 'pandemonium';\n\nrandomIndex(['apple', 'orange', 'pear']);\n>>> 1\n\n// Alternatively, you can give the array's length instead\nrandomIndex(3);\n>>> 2\n\n// To create your own function using custom RNG\nimport {createRandomIndex} from 'pandemonium/random-index';\n\nconst customRandomIndex = createRandomIndex(rng);\n```\n\n## randomString\n\nFunction returning a random string.\n\n```js\nimport randomString from 'pandemonium/random-string';\n// Or\nimport {randomString} from 'pandemonium';\n\n// To generate a string of fixed length\nrandomString(5);\n>>> 'gHepM'\n\n// To generate a string of variable length\nrandomString(3, 7);\n>>> 'hySf3'\n\n// To create your own function using custom RNG\nimport {createRandomString} from 'pandemonium/random-string';\n\nconst customRandomString = createRandomString(rng);\n\n// If you need a custom alphabet\nconst customRandomString = createRandomString(rng, 'ATGC');\n```\n\n## randomUint32\n\nFunction returning a random unsigned 32bits number.\n\n```js\nimport {randomUint32} from 'pandemonium/random-typed-int';\n// Or\nimport {randomUint32} from 'pandemonium';\n\nrandomUint32();\n>>> 397536\n\n// To create your own function using custom RNG\nimport {createRandomUint32} from 'pandemonium/random-typed-int';\n\nconst customRandomUint32 = createRandomUint32(rng);\n```\n\n## randomPair\n\nFunction returning a random pair from the given array.\n\nNote that this function will return unordered pairs (i.e. `[0, 1]` and `[1, 0]` are to be considered the same) and will not return pairs containing twice the same item (i.e. `[0, 0]`).\n\n```js\nimport randomPair from 'pandemonium/random-pair';\n// Or\nimport {randomPair} from 'pandemonium';\n\nrandomPair(['apple', 'orange', 'pear', 'cherry']);\n>>> ['orange', 'cherry']\n\n// Alternatively, you can give the array's length instead and get a pair of indices\nrandomPair(4);\n>>> [1, 3]\n\n// To create your own function using custom RNG\nimport {createRandomPair} from 'pandemonium/random-pair';\n\nconst customRandomPair = createRandomPair(rng);\n```\n\n## randomOrderedPair\n\nFunction returning a random ordered pair (i.e. `[0, 1]` won't be considered to be the same as `[1, 0]`) from the given array.\n\n```js\nimport randomOrderedPair from 'pandemonium/random-ordered-pair';\n// Or\nimport {randomOrderedPair} from 'pandemonium';\n\nrandomOrderedPair(['apple', 'orange', 'pear', 'cherry']);\n>>> ['cherry', 'apple']\n\n// Alternatively, you can give the array's length instead and get a pair of indices\nrandomOrderedPair(4);\n>>> [3, 0]\n\n// To create your own function using custom RNG\nimport {createRandomOrderedPair} from 'pandemonium/random-ordered-pair';\n\nconst customRandomPair = createRandomOrderedPair(rng);\n```\n\n## shuffle\n\nFunction returning a shuffled version of the given array using the Fisher-Yates algorithm.\n\nIf what you need is to shuffle the original array in place, check out [`shuffleInPlace`](#shuffleinplace).\n\n```js\nimport shuffle from 'pandemonium/shuffle';\n// Or\nimport {shuffle} from 'pandemonium';\n\nshuffle(['apple', 'orange', 'pear', 'pineapple']);\n>>> ['pear', 'orange', 'apple', 'pineapple']\n\n// To create your own function using custom RNG\nimport {createShuffle} from 'pandemonium/shuffle';\n\nconst customShuffle = createShuffle(rng);\n```\n\n## shuffleInPlace\n\nFunction shuffling the given array in place using the Fisher-Yates algorithm.\n\n```js\nimport shuffleInPlace from 'pandemonium/shuffle-in-place';\n// Or\nimport {shuffleInPlace} from 'pandemonium';\n\nconst array = ['apple', 'orange', 'pear', 'pineapple'];\nshuffleInPlace(array);\n\n// Array was mutated:\narray >>> ['pear', 'orange', 'apple', 'pineapple'];\n\n// To create your own function using custom RNG\nimport {createShuffleInPlace} from 'pandemonium/shuffle-in-place';\n\nconst customShuffleInPlace = createShuffleInPlace(rng);\n```\n\n## weightedChoice\n\nFunction returning a random item from the given array of weights.\n\nNote that weights don't need to be relative.\n\n```js\nimport weightedChoice from 'pandemonium/weighted-choice';\n// Or\nimport {weightedChoice} from 'pandemonium';\n\nconst array = [.1, .1, .4, .3, .1];\nweightedChoice(array);\n>>> .4\n\n// To create your own function using custom RNG\nimport {createWeightedChoice} from 'pandemonium/weighted-choice';\n\nconst customWeightedChoice = createWeightedChoice(rng);\n\n// If you have an array of objects\nconst customWeightedChoice = createWeightedChoice({\n  rng: rng,\n  getWeight: (item, index) => {\n    return item.weight;\n  }\n});\n\nconst array = [{fruit: 'pear', weight: 4}, {fruit: 'apple', weight: 30}];\ncustomWeightedChoice(array);\n>>> 'apple'\n\n\n// If you intent to call the function multiple times on the same array,\n// you should use the cached version instead:\nimport {createCachedWeightedChoice} from 'pandemonium/weighted-choice';\n\nconst array = [.1, .1, .4, .3, .1];\nconst customWeightedChoice = createCachedWeightedChoice(rng, array);\n\ncustomWeightedChoice();\n>>> .3\n```\n\n## weightedRandomIndex\n\nFunction returning a random index from the given array of weights.\n\nNote that weights don't need to be relative.\n\n```js\nimport weightedRandomIndex from 'pandemonium/weighted-random-index';\n// Or\nimport {weightedRandomIndex} from 'pandemonium';\n\nconst array = [.1, .1, .4, .3, .1];\nweightedRandomIndex(array);\n>>> 2\n\n// To create your own function using custom RNG\nimport {createWeightedRandomIndex} from 'pandemonium/weighted-random-index';\n\nconst customWeightedRandomIndex = createWeightedRandomIndex(rng);\n\n// If you have an array of objects\nconst customWeightedRandomIndex = createWeightedRandomIndex({\n  rng: rng,\n  getWeight: (item, index) => {\n    return item.weight;\n  }\n});\n\nconst array = [{fruit: 'pear', weight: 4}, {fruit: 'apple', weight: 30}];\ncustomWeightedRandomIndex(array);\n>>> 1\n\n\n// If you intent to call the function multiple times on the same array,\n// you should use the cached version instead:\nimport {createCachedWeightedRandomIndex} from 'pandemonium/weighted-random-index';\n\nconst array = [.1, .1, .4, .3, .1];\nconst customWeightedRandomIndex = createCachedWeightedRandomIndex(rng, array);\n\ncustomWeightedRandomIndex();\n>>> 3\n```\n\n## dangerouslyMutatingSample\n\nFunction returning a random sample of size `k` from the given array.\n\nThis function runs in `O(k)` time & memory but is somewhat dangerous because it will mutate the given array while performing its Fisher-Yates shuffle before reverting the mutations at the end.\n\n```js\nimport dangerouslyMutatingSample from 'pandemonium/dangerously-mutating-sample';\n// Or\nimport {dangerouslyMutatingSample} from 'pandemonium';\n\ndangerouslyMutatingSample(2, ['apple', 'orange', 'pear', 'pineapple']);\n>>> ['apple', 'pear']\n\n// To create your own function using custom RNG\nimport {createDangerouslyMutatingSample} from 'pandemonium/dangerously-mutating-sample';\n\nconst customSample = createDangerouslyMutatingSample(rng);\n```\n\n## fisherYatesSample\n\nFunction returning a random sample of size `k` from the given array.\n\nThis function uses a partial Fisher-Yates shuffle and therefore runs in `O(k)` time but must clone the given array to work, which adds `O(n)` time & memory.\n\n```js\nimport fisherYatesSample from 'pandemonium/fisher-yates-sample';\n// Or\nimport {fisherYatesSample} from 'pandemonium';\n\nfisherYatesSample(2, ['apple', 'orange', 'pear', 'pineapple']);\n>>> ['apple', 'pear']\n\n// To create your own function using custom RNG\nimport {createFisherYatesSample} from 'pandemonium/fisherYatesSample';\n\nconst customFisherYatesSample = createFisherYatesSample(rng);\n```\n\n## geometricReservoirSample\n\nFunction returning a random sample of size `k` from the given array.\n\nThis function runs in `O(k * (1 + log(n / k)))` time & `O(k)` memory using \"Algorithm L\" taken from the following paper:\n\n> Li, Kim-Hung. \"Reservoir-sampling algorithms of time complexity O(n (1+ log (N/n))).\" ACM Transactions on Mathematical Software (TOMS) 20.4 (1994): 481-493.\n\nNote that this function is able to sample indices without requiring you to represent the range of indices in memory.\n\n```js\nimport geometricReservoirSample from 'pandemonium/geometric-reservoir-sample';\n// Or\nimport {geometricReservoirSample} from 'pandemonium';\n\ngeometricReservoirSample(2, ['apple', 'orange', 'pear', 'pineapple']);\n>>> ['apple', 'pear']\n\n// Alternatively, you can pass a length and get a sample of indices back\ngeometricReservoirSample(2, 4);\n>>> [0, 2]\n\n// To create your own function using custom RNG\nimport {createGeometricReservoirSample} from 'pandemonium/geometric-reservoir-sample';\n\nconst customSample = createGeometricReservoirSample(rng);\n```\n\n## naiveSample\n\nFunction returning a random sample of size `k` from the given array.\n\nThis function works by keeping a `Set` of the already picked items and choosing a random item in the array until we have the desired `k` items.\n\nWhile it is a good pick for cases when `k` is little compared to the size of your array, this function will see its performance drop really fast when `k` becomes proportionally bigger.\n\nNote that this function is able to sample indices without requiring you to represent the range of indices in memory.\n\n```js\nimport naiveSample from 'pandemonium/naive-sample';\n// Or\nimport {naiveSample} from 'pandemonium';\n\nnaiveSample(2, ['apple', 'orange', 'pear', 'pineapple']);\n>>> ['apple', 'pear']\n\n// Alternatively, you can pass a length and get a sample of indices back\nnaiveSample(2, 4);\n>>> [0, 2]\n\n// To create your own function using custom RNG\nimport {createNaiveSample} from 'pandemonium/naive-sample';\n\nconst customSample = createNaiveSample(rng);\n```\n\n## reservoirSample\n\nFunction returning a random sample of size `k` from the given array.\n\nThis function runs in `O(n)` time and `O(k)` memory.\n\nA helper class able to work on an arbitrary stream of data that does not need to fit into memory is also available if you need it.\n\n```js\nimport reservoirSample from 'pandemonium/reservoir-sample';\n// Or\nimport {reservoirSample} from 'pandemonium';\n\nreservoirSample(2, ['apple', 'orange', 'pear', 'pineapple']);\n>>> ['apple', 'pear']\n\n// To create your own function using custom RNG\nimport {createReservoirSample} from 'pandemonium/reservoir-sample';\n\nconst customReservoirSample = createReservoirSample(rng);\n\n// To use the helper class\nimport {ReservoirSampler} from 'pandemonium/reservoir-sample';\n\n// If RNG is not provided, will default to Math.random\nconst sampler = new ReservoirSampler(10, rng);\n\nfor (const value of lazyIterable) {\n  sampler.process(value);\n}\n\n// To retrieve the sample once every value has been consumed\nconst sample = sampler.end();\n```\n\n## sampleWithReplacements\n\nFunction returning a random sample of size `k` with replacements from the given array. This prosaically means that an items from the array might occur several times in the resulting sample.\n\nThe function runs in both `O(k)` time & space complexity.\n\n```js\nimport sampleWithReplacements from 'pandemonium/sample-with-replacements';\n// Or\nimport {sampleWithReplacements} from 'pandemonium';\n\nsampleWithReplacements(3, ['apple', 'orange', 'pear', 'pineapple']);\n>>> ['apple', 'pear', 'apple']\n\n// To create your own function using custom RNG\nimport {createSampleWithReplacements} from 'pandemonium/sample-with-replacements';\n\nconst customSample = createSampleWithReplacements(rng);\n```\n\n## samplePairs\n\nFunction returning a random sample of `k` unique unordered pairs from the given array.\n\nIt works by storing a unique key created from the picked pairs, making it a specialized variant of [naiveSample](#naivesample).\n\nIt is usually quite efficient because when sampling pairs, the total size of the population, being combinatorial, is often magnitudes larger than the size of the sample we need to retrieve.\n\nNote finally that this function is able to sample pairs of indices without requiring you to represent the range of indices in memory.\n\n```js\nimport samplePairs from 'pandemonium/sample-pairs';\n// Or\nimport {samplePairs} from 'pandemonium';\n\nsamplePairs(2, ['apple', 'orange', 'pear', 'pineapple']);\n>>>  [['apple', 'pear'], ['orange', 'pear']]\n\n// Alternatively, you can pass a length and get a sample of pairs of indices\nsamplePairs(2, 4);\n>>> [[0, 2], [1, 2]]\n\n// To create your own function using custom RNG\nimport {createSamplePairs} from 'pandemonium/sample-pairs';\n\nconst customSamplePairs = createSamplePairs(rng);\n```\n\n## sampleOrderedPairs\n\nFunction returning a random sample of `k` unique ordered pairs from the given array.\n\nIt works by storing a unique key created from the picked pairs, making it a specialized variant of [naiveSample](#naivesample).\n\nIt is usually quite efficient because when sampling pairs, the total size of the population, being combinatorial, is often magnitudes larger than the size of the sample we need to retrieve.\n\nNote finally that this function is able to sample pairs of indices without requiring you to represent the range of indices in memory.\n\n```js\nimport sampleOrderedPairs from 'pandemonium/sample-pairs';\n// Or\nimport {sampleOrderedPairs} from 'pandemonium';\n\nsampleOrderedPairs(2, ['apple', 'orange', 'pear', 'pineapple']);\n>>>  [['apple', 'pear'], ['pear', 'orange']]\n\n// Alternatively, you can pass a length and get a sample of pairs of indices\nsampleOrderedPairs(2, 4);\n>>> [[0, 2], [2, 1]]\n\n// To create your own function using custom RNG\nimport {createSampleOrderedPairs} from 'pandemonium/sample-ordered-pairs';\n\nconst customSampleOrderedPairs = createSampleOrderedPairs(rng);\n```\n\n## weightedReservoirSample\n\nFunction returning a random sample of size `k` from a given array of weighted items.\n\nThe result is a sample without replacement, which, in the case of weighted items, has been chosen to mean that subsequent items are picked based on the proportional total weight of the remaining items.\n\nWe use algorithm \"A-ES\" from the following papers:\n\n> Pavlos S. Efraimidis, Paul G. Spirakis. \"Weighted random sampling with a reservoir.\" https://arxiv.org/pdf/1012.0256.pdf\n\n> Pavlos S. Efraimidis. \"Weighted Random Sampling over Data Streams.\"\n\nThis function runs in `O(n)` time and `O(k)` memory.\n\nA helper class working able to work on an arbitrary stream of data that does not need to fit into memory is also available if you need it.\n\n```js\nimport weightedReservoirSample from 'pandemonium/weighted-reservoir-sample';\n// Or\nimport {weightedReservoirSample} from 'pandemonium';\n\nweightedReservoirSample(2, [.1, .1, .4, .3, .05]);\n>>> [.3, .4]\n\n// To create your own function using custom RNG\nimport {createWeightedReservoirSample} from 'pandemonium/weighted-reservoir-sample';\n\nconst customWeightedReservoirSample = createWeightedReservoirSample(rng);\n\n// To sample arbitrary items\nconst data = [{label: 'orange', importance: 34}, ...];\n\nconst customWeightedReservoirSample = createWeightedReservoirSample({\n  getWeight: item => item.importance\n});\n\n// To use the helper class\nimport {WeightedReservoirSampler} from 'pandemonium/weighted-reservoir-sample';\n\n// If RNG is not provided, will default to Math.random\nconst sampler = new WeightedReservoirSampler(10, {rng, getWeight});\n\nfor (const value of lazyIterable) {\n  sampler.process(value);\n}\n\n// To retrieve the sample once every value has been consumed\nconst sample = sampler.end();\n```\n\n# Contribution\n\nContributions are obviously welcome. Please be sure to lint the code & add the relevant unit tests before submitting any PR.\n\n```\ngit clone git@github.com:Yomguithereal/pandemonium.git\ncd pandemonium\nnpm install\n\n# To lint the code\nnpm run lint\n\n# To run the unit tests\nnpm test\n```\n\n# License\n\n[MIT](LICENSE.txt)\n","_attachments":{},"homepage":"https://github.com/yomguithereal/pandemonium#readme","bugs":{"url":"https://github.com/yomguithereal/pandemonium/issues"},"license":"MIT"}