· Homepage · Report Bug / Request Feature ·
npm install @compactjs/random
/**
* Returns a pseudo random number between min and max.
* (min inclusive, max exclusive)
* Max can be smaller than min.
* If max is not omitted, between 0 and min.
* If min is not omitted, between 0 and 1.
*/
function random(min?: number, max?: number): number;
/**
* Returns a random item from a given array
* @param choices to select from
*/
function pick(choices: any[]): any;
import { random, pick } from '@compactjs/random';
random(10, 100); // => random value between (including) 10 and 100
random(10); // => random value between 0 and 10
random(); // => random value between 0 and 1
pick([0, 1, 2, 3]); // => picks random value from 0,1,2,3
npm run test
👤 Timo Bechtel
- Website: https://timobechtel.com
- Twitter: @TimoBechtel
- GitHub: @TimoBechtel
Contributions, issues and feature requests are welcome!
- Check issues
- Fork the Project
- Create your Feature Branch (
git checkout -b feat/AmazingFeature
) - Test your changes
npm run test
- Commit your Changes (
git commit -m 'feat: add amazingFeature'
) - Push to the Branch (
git push origin feat/AmazingFeature
) - Open a Pull Request
This project uses semantic-release for automated release versions. So commits in this project follow the Conventional Commits guidelines. I recommend using commitizen for automated commit messages.
Give a ⭐️ if this project helped you!
Distributed under the MIT License.
This README was generated with ❤️ by readme-md-generator