This package has been deprecated

Author message:

Please use @codebundlesbyvik/js-helpers instead. Migration will only take a minute - I promise!

@codebundlesbyvik/number-operations

1.0.2 • Public • Published

number-operations

npm npm - downloads per week

JavaScript helper functions for number operations.


Installation

// Install package from npm
npm install @codebundlesbyvik/number-operations

import getRandomIntUnder from "@codebundlesbyvik/number-operations";

Functions

getRandomIntUnder(max, includeMax)

Generate and return a random integer below a given number.

⚠️ Makes use of Math.random(), which ISN'T cryptographically secure. Do NOT use this for generating secure, random integers. ⚠️

Parameters

* indicates required

  • * max (Number): Depending on includeMax, the returned integer will be either equal to or below this number.
  • includeMax (Boolean): Whether or not to include max when generating the integer. Default is undefined, which functions as false.

Usage

getRandomIntUnder(10)
// > 7

getRandomIntUnder(10, true)
// > 10

License

MIT © Viktor Chin-Kon-Sung

/@codebundlesbyvik/number-operations/

    Package Sidebar

    Install

    npm i @codebundlesbyvik/number-operations

    Weekly Downloads

    1

    Version

    1.0.2

    License

    MIT

    Unpacked Size

    3.75 kB

    Total Files

    5

    Last publish

    Collaborators

    • codebundlesbyvik