Socket
Socket
Sign inDemoInstall

@compactjs/random

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @compactjs/random

Simple module to generate random values from a given range or array


Version published
Maintainers
1
Install size
10.2 kB
Created

Changelog

Source

1.0.1 (2020-06-22)

Bug Fixes

  • readme: update links to reflect branch renaming (4ea2293)

Features

Readme

Source

🎲
@compactjs/random

Simple module to generate random values from a given range or array.

Version License: MIT

· Homepage · Report Bug / Request Feature ·

Table of Contents

Install

NPM:

npm install @compactjs/random

Usage

/**
 * 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;

As module:

import { random, pick } from '@compactjs/random';

Example:

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

Run tests

npm run test

Contact

👤 Timo Bechtel

🤝 Contributing

Contributions, issues and feature requests are welcome!

  1. Check issues
  2. Fork the Project
  3. Create your Feature Branch (git checkout -b feat/AmazingFeature)
  4. Test your changes npm run test
  5. Commit your Changes (git commit -m 'feat: add amazingFeature')
  6. Push to the Branch (git push origin feat/AmazingFeature)
  7. Open a Pull Request

Commit messages

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.

Show your support

Give a ⭐️ if this project helped you!

📝 License

Distributed under the MIT License.


This README was generated with ❤️ by readme-md-generator

Keywords

FAQs

Last updated on 22 Jun 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc