JSPM

random.js

0.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 918
  • Score
    100M100P100Q101126F

random numbers and string generation

Package Exports

  • random.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (random.js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

random.js

javascript random numbers and string generation library

usage:

use it from your html page:

    <script type="text/javascript" src="random.js"></script>

or from a node.js project

    // in your package.json
    dependencies: [
        "random.js": "0.1.0"
    ]
    // in your js file
    var random = require('random')

functions:

  • randomInt([options]): generate random integers

    • parameters:
      • options:Object
        • min:Int:
          the minimum value (default: 0)
        • max:Int:
          the maximum value (default: 4294967295)
    • returns: an integer between the min/max bounds
  • randomFloat([options]): generate random floats

    • parameters:
      • options:Object:
        • min:Float:
          the minimum value (default: 0.0)
        • max:Float:
          the maximum value (default: 1.0)
    • returns an integer between the min/max bounds
  • randomString([options]): generate random strings

    • parameters:
      • options:Object
        • length:Int:
          the length of the string to generate (default: 20)
        • set:String:
          one of "alpha" | "numeric" | "alphanum" | "hex" | "custom" (default: "alphanum")
        • custom:String/Array<char>:
          if set is "custom", provides a set of characters used for the string generation
        • returns a string containing random characters from the selected set of the given length
        • note: when generating hexadecimal strings, the alpha-characters are uppercase, use .toLowerCase() on the result to switch to lowercase