{"_id":"random-int","_rev":"4106773","name":"random-int","description":"Generate a random integer","dist-tags":{"latest":"3.1.0"},"maintainers":[{"name":"sindresorhus","email":""}],"time":{"modified":"2026-01-11T18:56:31.000Z","created":"2015-06-26T22:26:10.326Z","3.1.0":"2025-09-15T12:06:44.083Z","3.0.0":"2021-04-17T18:02:14.535Z","2.0.1":"2019-09-14T08:30:39.409Z","2.0.0":"2019-04-11T05:08:28.680Z","1.0.0":"2015-06-26T22:26:10.326Z"},"users":{},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"repository":{"type":"git","url":"git+https://github.com/sindresorhus/random-int.git"},"versions":{"3.1.0":{"name":"random-int","version":"3.1.0","description":"Generate a random integer","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/random-int.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":"./index.js","types":"./index.d.ts","sideEffects":false,"engines":{"node":">=12"},"scripts":{"//test":"xo && ava && tsd","test":"ava"},"keywords":["random","randomize","int","integer","number","max","min","math","generate","generator"],"devDependencies":{"ava":"^3.15.0","in-range":"^3.0.0","stable-function":"^4.0.0","tsd":"^0.14.0","xo":"^0.38.2"},"_id":"random-int@3.1.0","gitHead":"f322b1367550b95898264ad158a41695af60bfdf","bugs":{"url":"https://github.com/sindresorhus/random-int/issues"},"homepage":"https://github.com/sindresorhus/random-int#readme","_nodeVersion":"20.19.1","_npmVersion":"10.9.2","dist":{"shasum":"ab096f7106c83cdcea975b0b0d4394417677609e","size":1965,"noattachment":false,"key":"/random-int/-/random-int-3.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/random-int/download/random-int-3.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/random-int_3.1.0_1757938003904_0.7195050625452992"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-09-15T12:06:44.083Z","publish_time":1757938004083,"_source_registry_name":"default","_cnpm_publish_time":1757938004083},"3.0.0":{"name":"random-int","version":"3.0.0","description":"Generate a random integer","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/random-int.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"},"scripts":{"test":"xo && ava && tsd"},"keywords":["random","randomize","int","integer","number","max","min","math","generate","generator"],"devDependencies":{"ava":"^3.15.0","in-range":"^3.0.0","stable-fn":"^3.0.0","tsd":"^0.14.0","xo":"^0.38.2"},"gitHead":"1b0bc5861b1256abd456ced258239f1251dc48a9","bugs":{"url":"https://github.com/sindresorhus/random-int/issues"},"homepage":"https://github.com/sindresorhus/random-int#readme","_id":"random-int@3.0.0","_nodeVersion":"12.22.1","_npmVersion":"6.14.10","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"69782559c9306c43de1dd174ea616330ef75b749","size":1859,"noattachment":false,"key":"/random-int/-/random-int-3.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/random-int/download/random-int-3.0.0.tgz"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/random-int_3.0.0_1618682534398_0.7190264400266932"},"_hasShrinkwrap":false,"publish_time":1618682534535,"_cnpm_publish_time":1618682534535,"_cnpmcore_publish_time":"2021-12-14T15:37:25.323Z"},"2.0.1":{"name":"random-int","version":"2.0.1","description":"Generate a random integer","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/random-int.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=8"},"scripts":{"test":"xo && ava && tsd"},"keywords":["rand","random","randomize","int","integer","number","max","min","math","generate","generator"],"devDependencies":{"ava":"^1.4.1","in-range":"^2.0.0","stable-fn":"^2.0.0","tsd":"^0.7.2","xo":"^0.24.0"},"gitHead":"c37741b56f76b9160b0b63dae4e9c64875128146","bugs":{"url":"https://github.com/sindresorhus/random-int/issues"},"homepage":"https://github.com/sindresorhus/random-int#readme","_id":"random-int@2.0.1","_nodeVersion":"10.16.0","_npmVersion":"6.11.3","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"d072fe298e2fd12a730edde7729168b7b88dcea3","size":1926,"noattachment":false,"key":"/random-int/-/random-int-2.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/random-int/download/random-int-2.0.1.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/random-int_2.0.1_1568449839235_0.22795215734552476"},"_hasShrinkwrap":false,"publish_time":1568449839409,"_cnpm_publish_time":1568449839409,"_cnpmcore_publish_time":"2021-12-14T15:37:25.531Z"},"2.0.0":{"name":"random-int","version":"2.0.0","description":"Generate a random integer","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/random-int.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=8"},"scripts":{"test":"xo && ava && tsd"},"keywords":["rand","random","randomize","int","integer","number","max","min","math","generate","generator"],"devDependencies":{"ava":"^1.4.1","in-range":"^2.0.0","stable-fn":"^2.0.0","tsd":"^0.7.2","xo":"^0.24.0"},"gitHead":"7ab2dd39099b5577527eaad5e548f3f2fbdf5784","bugs":{"url":"https://github.com/sindresorhus/random-int/issues"},"homepage":"https://github.com/sindresorhus/random-int#readme","_id":"random-int@2.0.0","_npmVersion":"6.4.1","_nodeVersion":"10.15.1","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"0979bdef46207a11dbfdbf6cae980351ba8946ab","size":1943,"noattachment":false,"key":"/random-int/-/random-int-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/random-int/download/random-int-2.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/random-int_2.0.0_1554959308538_0.27391851100245757"},"_hasShrinkwrap":false,"publish_time":1554959308680,"_cnpm_publish_time":1554959308680,"_cnpmcore_publish_time":"2021-12-14T15:37:25.732Z"},"1.0.0":{"name":"random-int","version":"1.0.0","description":"Generate a random integer","license":"MIT","repository":{"type":"git","url":"https://github.com/sindresorhus/random-int"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=0.10.0"},"scripts":{"test":"node test.js"},"files":["index.js"],"keywords":["rand","random","randomize","int","integer","num","number","max","min","math","gen","generate","generator"],"devDependencies":{"ava":"0.0.4","in-range":"^1.0.0","number-is-integer":"^1.0.0","stable-fn":"^1.0.0"},"gitHead":"515c1fdbb87b496c95c77e34f9fe9268c3a9cf7a","bugs":{"url":"https://github.com/sindresorhus/random-int/issues"},"homepage":"https://github.com/sindresorhus/random-int","_id":"random-int@1.0.0","_shasum":"e6a2ed3448ac9c6646a0657443b1c1521592ed08","_from":".","_npmVersion":"2.11.2","_nodeVersion":"0.12.5","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"e6a2ed3448ac9c6646a0657443b1c1521592ed08","size":1788,"noattachment":false,"key":"/random-int/-/random-int-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/random-int/download/random-int-1.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"publish_time":1435357570326,"_hasShrinkwrap":false,"_cnpm_publish_time":1435357570326,"_cnpmcore_publish_time":"2021-12-14T15:37:25.963Z"}},"readme":"# random-int\n\n> Generate a random integer\n\n## Install\n\n```sh\nnpm install random-int\n```\n\n## Usage\n\n```js\nimport randomInteger from 'random-int';\n\nrandomInteger(5);\n//=> 3\n\nrandomInteger(10, 100);\n//=> 54\n```\n\n## API\n\n### randomInteger(maximum?)\n\nReturns an integer from `0` to `maximum`.\n\n### randomInteger(minimum, maximum)\n\nReturns an integer from `minimum` to `maximum`.\n\nIf `minimum` is greater than `maximum`, the values are swapped to return an integer from the lower value to the higher value.\n\n#### minimum\n\nType: `number`\\\nDefault: `0`\n\nMinimum integer to return.\n\n#### maximum\n\nType: `number`\\\nDefault: `1`\n\nMaximum integer to return.\n\n## Related\n\n- [random-float](https://github.com/sindresorhus/random-float) - Generate a random float\n- [random-item](https://github.com/sindresorhus/random-item) - Get a random item from an array\n- [random-object-key](https://github.com/sindresorhus/random-object-key) - Get a random key from an object\n- [random-object-value](https://github.com/sindresorhus/random-object-value) - Get a random value from an object\n- [unique-random](https://github.com/sindresorhus/unique-random) - Generate random numbers that are consecutively unique\n- [unique-random-array](https://github.com/sindresorhus/unique-random-array) - Get consecutively unique elements from an array\n- [crypto-random-string](https://github.com/sindresorhus/crypto-random-string) - Generate a cryptographically strong random string\n","_attachments":{},"homepage":"https://github.com/sindresorhus/random-int#readme","bugs":{"url":"https://github.com/sindresorhus/random-int/issues"},"license":"MIT"}