{"_id":"@alexrah/react-use-random-number-hook","_rev":"5-ffda115371fe3e81d42916055d21e34f","name":"@alexrah/react-use-random-number-hook","dist-tags":{"latest":"0.2.3"},"versions":{"0.1.0":{"name":"@alexrah/react-use-random-number-hook","version":"0.1.0","author":{"name":"alessandro stoppato"},"license":"MIT","_id":"@alexrah/react-use-random-number-hook@0.1.0","maintainers":[{"name":"alexrah","email":"alexrah@gmail.com"}],"homepage":"https://github.com/alexrah/react-use-random-hook#readme","bugs":{"url":"https://github.com/alexrah/react-use-random-hook/issues"},"dist":{"shasum":"33caa9c67e288f93584f744b240a30b80214fcb7","tarball":"https://registry.npmjs.org/@alexrah/react-use-random-number-hook/-/react-use-random-number-hook-0.1.0.tgz","fileCount":11,"integrity":"sha512-vitz1tg/5sPwYnG1/lgCwx2E5HASi1bDOmZdc3o3aing6Ho2V/7DkAGw3amWFFnnJ0AM8lBFTAsNkVgKqjbCRg==","signatures":[{"sig":"MEUCIQDBbcY+bITQcvYAzRQ0YxtcrsDtTQ2gEGF8LTvWJaXHpQIgaan1aceBoBeXrojHed7q4Haj4xPrZaUuftDmLngoBJU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16290},"main":"dist/index.js","husky":{"hooks":{"pre-commit":"tsdx lint"}},"module":"dist/react-use-random-hook.esm.js","engines":{"node":">=10"},"gitHead":"e4fb7461a85a959b3cc1c96cee05f0ba9a32159d","scripts":{"lint":"tsdx lint","size":"size-limit","test":"tsdx test --passWithNoTests","build":"tsdx build","start":"tsdx watch","analyze":"size-limit --why","prepare":"tsdx build"},"typings":"dist/index.d.ts","_npmUser":{"name":"alexrah","email":"alexrah@gmail.com"},"prettier":{"semi":true,"printWidth":80,"singleQuote":true,"trailingComma":"es5"},"deprecated":"superseded by @alexrah/react-use-random-hook, please install the newer package","repository":{"url":"git+https://github.com/alexrah/react-use-random-hook.git","type":"git"},"size-limit":[{"path":"dist/react-use-random-hook.cjs.production.min.js","limit":"10 KB"},{"path":"dist/react-use-random-hook.esm.js","limit":"10 KB"}],"_npmVersion":"10.2.4","description":"Congrats! You just saved yourself hours of work by bootstrapping this project with TSDX. Let’s get you oriented with what’s here and how to use it.","directories":{},"_nodeVersion":"20.11.1","_hasShrinkwrap":false,"devDependencies":{"tsdx":"^0.14.1","husky":"^9.1.5","react":"^18.3.1","tslib":"^2.7.0","react-dom":"^18.3.1","size-limit":"^11.1.4","typescript":"^5.5.4","@types/react":"^17.0.80","@types/react-dom":"^17.0.25","@size-limit/preset-small-lib":"^11.1.4"},"peerDependencies":{"react":">=17"},"_npmOperationalInternal":{"tmp":"tmp/react-use-random-number-hook_0.1.0_1725367718461_0.7275552445727258","host":"s3://npm-registry-packages"}},"0.2.1":{"name":"@alexrah/react-use-random-number-hook","version":"0.2.1","author":{"name":"alessandro stoppato"},"license":"MIT","_id":"@alexrah/react-use-random-number-hook@0.2.1","maintainers":[{"name":"alexrah","email":"alexrah@gmail.com"}],"homepage":"https://github.com/alexrah/react-use-random-hook#readme","bugs":{"url":"https://github.com/alexrah/react-use-random-hook/issues"},"dist":{"shasum":"69ad03e1545d678b03215334e3e8df1b25cc9b68","tarball":"https://registry.npmjs.org/@alexrah/react-use-random-number-hook/-/react-use-random-number-hook-0.2.1.tgz","fileCount":11,"integrity":"sha512-11p1KOvCfv2YGfPbRUOOSFm46UuGeMlJLzqio9/SeB9jbS1e0jrwn5hQWmE/7Ah92jc+iItomevCPHzGdylc4Q==","signatures":[{"sig":"MEUCIQDJUqTF35GX6Md+zUH6WJxNhJHdnZh3E6Xfmk3gL7yEkAIgAY/djOXroS6c25g2QIO7L+tDJf76uYZxrsnO7cUcFeU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13870},"main":"dist/index.js","husky":{"hooks":{"pre-commit":"tsdx lint"}},"module":"dist/react-use-random-hook.esm.js","engines":{"node":">=10"},"gitHead":"101c4d42085635ad7ad3d635dbbe7fcb5e40144e","scripts":{"lint":"tsdx lint","size":"size-limit","test":"tsdx test --passWithNoTests","build":"tsdx build","start":"tsdx watch","analyze":"size-limit --why","prepare":"tsdx build"},"typings":"dist/index.d.ts","_npmUser":{"name":"alexrah","email":"alexrah@gmail.com"},"prettier":{"semi":true,"printWidth":80,"singleQuote":true,"trailingComma":"es5"},"deprecated":"superseded by @alexrah/react-use-random-hook, please install the newer package","repository":{"url":"git+https://github.com/alexrah/react-use-random-hook.git","type":"git"},"size-limit":[{"path":"dist/react-use-random-hook.cjs.production.min.js","limit":"10 KB"},{"path":"dist/react-use-random-hook.esm.js","limit":"10 KB"}],"_npmVersion":"10.2.4","description":"A React hook for generating random numbers and keep them consistent between renders.","directories":{},"_nodeVersion":"20.11.1","_hasShrinkwrap":false,"devDependencies":{"tsdx":"^0.14.1","husky":"^9.1.5","react":"^17.0.2","tslib":"^2.7.0","react-dom":"^17.0.2","size-limit":"^11.1.4","typescript":"^5.5.4","@types/react":"^17.0.80","@types/react-dom":"^17.0.25","@size-limit/preset-small-lib":"^11.1.4"},"peerDependencies":{"react":">=17"},"_npmOperationalInternal":{"tmp":"tmp/react-use-random-number-hook_0.2.1_1725369532126_0.44390315466473695","host":"s3://npm-registry-packages"}},"0.2.2":{"name":"@alexrah/react-use-random-number-hook","version":"0.2.2","author":{"name":"alessandro stoppato"},"license":"MIT","_id":"@alexrah/react-use-random-number-hook@0.2.2","maintainers":[{"name":"alexrah","email":"alexrah@gmail.com"}],"homepage":"https://github.com/alexrah/react-use-random-hook#readme","bugs":{"url":"https://github.com/alexrah/react-use-random-hook/issues"},"dist":{"shasum":"f07da7dc581250efd2fa3faed1f3acf6347671c6","tarball":"https://registry.npmjs.org/@alexrah/react-use-random-number-hook/-/react-use-random-number-hook-0.2.2.tgz","fileCount":11,"integrity":"sha512-/ZKK8LXwz6bWznXnvWxj4ho4WqoOC9BXWftEU2x3XjeNPF2kmmpdbExk/inHQDndvbxvd9YXiCRVL1hepxMapA==","signatures":[{"sig":"MEQCIDqYURGJG7Pn7bcQ2U4gThmQPQIhZ5GL4LwkaQokL1U5AiBoTJcId9ud/IUHD7WwSBOZ2aFxGkPxDA7RpLNV8Vk7eQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13924},"main":"dist/index.js","husky":{"hooks":{"pre-commit":"tsdx lint"}},"module":"dist/react-use-random-hook.esm.js","engines":{"node":">=10"},"gitHead":"89b1099daa176eea17cc7eb9390a7ed87882410c","scripts":{"lint":"tsdx lint","size":"size-limit","test":"tsdx test --passWithNoTests","build":"tsdx build","start":"tsdx watch","analyze":"size-limit --why","prepare":"tsdx build"},"typings":"dist/index.d.ts","_npmUser":{"name":"alexrah","email":"alexrah@gmail.com"},"prettier":{"semi":true,"printWidth":80,"singleQuote":true,"trailingComma":"es5"},"deprecated":"superseded by @alexrah/react-use-random-hook, please install the newer package","repository":{"url":"git+https://github.com/alexrah/react-use-random-hook.git","type":"git"},"size-limit":[{"path":"dist/react-use-random-hook.cjs.production.min.js","limit":"10 KB"},{"path":"dist/react-use-random-hook.esm.js","limit":"10 KB"}],"_npmVersion":"10.2.4","description":"A React hook for generating random numbers and keep them consistent between renders.","directories":{},"_nodeVersion":"20.11.1","_hasShrinkwrap":false,"devDependencies":{"tsdx":"^0.14.1","husky":"^9.1.5","react":"^17.0.2","tslib":"^2.7.0","react-dom":"^17.0.2","size-limit":"^11.1.4","typescript":"^5.5.4","@types/react":"^17.0.80","@types/react-dom":"^17.0.25","@size-limit/preset-small-lib":"^11.1.4"},"peerDependencies":{"react":">=17"},"_npmOperationalInternal":{"tmp":"tmp/react-use-random-number-hook_0.2.2_1725369657888_0.4845311994544388","host":"s3://npm-registry-packages"}},"0.2.3":{"name":"@alexrah/react-use-random-number-hook","version":"0.2.3","keywords":["react","random","hooks","number"],"author":{"name":"alessandro stoppato"},"license":"MIT","_id":"@alexrah/react-use-random-number-hook@0.2.3","maintainers":[{"name":"alexrah","email":"alexrah@gmail.com"}],"homepage":"https://github.com/alexrah/react-use-random-hook#readme","bugs":{"url":"https://github.com/alexrah/react-use-random-hook/issues"},"dist":{"shasum":"05fb54141c6cfcb2c685df1ea76a4ca6f4a4f2ca","tarball":"https://registry.npmjs.org/@alexrah/react-use-random-number-hook/-/react-use-random-number-hook-0.2.3.tgz","fileCount":11,"integrity":"sha512-j6qnR0Mxbxwzi6KGce+CFjHEYPcn/XyA4vR4ZZXD/shVVpS4xAxbCrWwsJAmiWVn/xSfX1K7ii5BRSnoD9XNqQ==","signatures":[{"sig":"MEYCIQCQ+I9Id77piu3JNfsKB9DFk0TAWJaqaOfHP8IkY0HHtgIhAKOv4MPd4PLnvSG66R6zjrONwzIsY70taSlchMLaSyEy","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14104},"main":"dist/index.js","husky":{"hooks":{"pre-commit":"tsdx lint"}},"module":"dist/react-use-random-hook.esm.js","engines":{"node":">=10"},"gitHead":"b0c4867dfef5b13264fa2c8e2fa34b9c5d0549e2","scripts":{"lint":"tsdx lint","size":"size-limit","test":"tsdx test --passWithNoTests","build":"tsdx build","start":"tsdx watch","analyze":"size-limit --why","prepare":"tsdx build"},"typings":"dist/index.d.ts","_npmUser":{"name":"alexrah","email":"alexrah@gmail.com"},"prettier":{"semi":true,"printWidth":80,"singleQuote":true,"trailingComma":"es5"},"deprecated":"superseded by @alexrah/react-use-random-hook, please install the newer package","repository":{"url":"git+https://github.com/alexrah/react-use-random-hook.git","type":"git"},"size-limit":[{"path":"dist/react-use-random-hook.cjs.production.min.js","limit":"10 KB"},{"path":"dist/react-use-random-hook.esm.js","limit":"10 KB"}],"_npmVersion":"10.2.4","description":"A React hook for generating random numbers and keep them consistent between renders.","directories":{},"_nodeVersion":"20.11.1","_hasShrinkwrap":false,"devDependencies":{"tsdx":"^0.14.1","husky":"^9.1.5","react":"^17.0.2","tslib":"^2.7.0","react-dom":"^17.0.2","size-limit":"^11.1.4","typescript":"^5.5.4","@types/react":"^17.0.80","@types/react-dom":"^17.0.25","@size-limit/preset-small-lib":"^11.1.4"},"peerDependencies":{"react":">=17"},"_npmOperationalInternal":{"tmp":"tmp/react-use-random-number-hook_0.2.3_1725369822746_0.44283224445835345","host":"s3://npm-registry-packages"}}},"time":{"created":"2024-09-03T12:48:38.387Z","modified":"2024-09-04T17:31:02.384Z","0.1.0":"2024-09-03T12:48:38.635Z","0.2.1":"2024-09-03T13:18:52.289Z","0.2.2":"2024-09-03T13:20:58.174Z","0.2.3":"2024-09-03T13:23:42.931Z"},"bugs":{"url":"https://github.com/alexrah/react-use-random-hook/issues"},"author":{"name":"alessandro stoppato"},"license":"MIT","homepage":"https://github.com/alexrah/react-use-random-hook#readme","keywords":["react","random","hooks","number"],"repository":{"url":"git+https://github.com/alexrah/react-use-random-hook.git","type":"git"},"description":"A React hook for generating random numbers and keep them consistent between renders.","maintainers":[{"name":"alexrah","email":"alexrah@gmail.com"}],"readme":"# React useRandom() Hook\n\nA React hook for generating random numbers and keep them consistent between renders.\n\n## Overview\n\nThis package exports a React hook, `useRandomNumber`, which generates a random number between 0 and 1. The hook also provides a provider, `RandomNumberProvider`, which is required to enable `useRandomNumber`.\n\n## Exported Functions\n\n\n### `RandomNumberProvider`\n\n```typescript\nimport { RandomNumberProvider } from '@alexrah/react-use-random-hook';\n\nconst App = () => {\n  <RandomNumberProvider>\n    // ...\n  </RandomNumberProvider>\n};\n```\n\nThe `RandomNumberProvider` provider provides a way to share the random number with other components and keep the generated number consistent between renders.\n\n#### `RandomNumberProvider` props\n\nThe `base` prop in `RandomNumberProvider` is an optional parameter that allows you to specify the upper limit of the random number generated.\n\nAccording to the code snippet from `src/index.tsx:RandomNumberProvider`, the `base` prop is used to multiply the random number generated by `Math.random()`. This means that the random number will be generated between 0 and the value of `base`.\n\nHere's the relevant code snippet:\n```typescript\nconst [random, ] = React.useState<number>( () =>{return Math.random()*base});\n```\nIf you don't provide a `base` prop, it will default to 1, which means the random number will be generated between 0 and 1.\n\nBy providing a `base` prop, you can generate random numbers within a specific range. For example, if you set `base` to 100, the random number will be generated between 0 and 100.\n\nHere's an example of how you can use the `base` prop:\n```typescript\nimport { RandomNumberProvider } from '@alexrah/react-use-random-hook';\n\nconst App = () => {\n  <RandomNumberProvider base={100}>\n    // ...\n  </RandomNumberProvider>\n};\n```\nIn this example, the random number generated will be between 0 and 100.\n\n\n### `useRandomNumber`\n\n```typescript\nimport { useRandomNumber } from '@alexrah/react-use-random-hook';\n\nconst random = useRandomNumber();\n```\n\nThe `useRandomNumber` hook returns a random number between 0 and 1. The number does not change between renders.\n\n\n## Scripts\n---------\n\nThe package defines several scripts in `package.json`:\n\n### `start`\n\n```bash\nnpm start\n```\n\nThe `start` script runs the `tsdx watch` command, which builds the package and runs it in watch mode. This means that any changes to the code will trigger a rebuild and re-run of the package.\n\n### `build`\n\n```bash\nnpm run build\n```\n\nThe `build` script runs the `tsdx build` command, which builds the package and generates the output files in the `dist` directory.\n\n### `test`\n\n```bash\nnpm test\n```\n\nThe `test` script runs the `tsdx test` command, which runs the tests.\n\n### `lint`\n\n```bash\nnpm run lint\n```\n\nThe `lint` script runs the `tsdx lint` command, which checks the code for any linting errors.\n\n### `size`\n\n```bash\nnpm run size\n```\n\nThe `size` script runs the `size-limit` command, which checks the size of the output files in the `dist` directory.\n\n### `analyze`\n\n```bash\nnpm run analyze\n```\n\nThe `analyze` script runs the `size-limit --why` command, which provides more detailed information about the size of the output files in the `dist` directory.\n\n## Example Usage\n---------------\n\nHere is an example of how to use the `useRandom` hook:\n```typescript\nimport React from 'react';\nimport { useRandomNumber, RandomNumberProvider } from '@alexrah/react-use-random-hook';\n\nconst App = () => {\n  const random = useRandomNumber();\n  return <div>Random number: {random}</div>;\n};\n\nReactDOM.render(<RandomNumberProvider><App/></RandomNumberProvider>, document.getElementById('root'));\n\n```\nThis code defines a React component that uses the `useRandomNumber` hook to generate a random number, and then displays the number in a `div` element.\n\n","readmeFilename":"README.md"}