npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

random.org-javascript

v1.0.4

Published

Random.org API for Node.JS

Downloads

7

Readme

random.org.js NPM Version Build Status Dependencies Vuln

Table of Contents

Installation

Install with npm

$ npm install random.org-javascript

Usage

ES6

import random from "random.org-javascript";

CommonJS

const random = require("random.org-javascript");

Basic Example

You can use Promise

random.generateInteger(1, 50, 10, "Decimal").then(response => {
    console.log(response); // => Array<number>[10]
}).catch(error => {
    console.log(error);
});

or async

try {
    let response = await random.generateInteger(10, 50, 10, "Decimal")
    console.log(response); // => Array<number>[10]
} catch (error) {
    console.log(error);
}

Examples

Generating Random Number

random.generateInteger(1, 50, 10, "Decimal").then(response => {
    console.log(response); // => Array<number>[10]
}).catch(error => {
    console.log(error);
});

Generating Random Number Sequence

random.generateIntegerSequences(1, 50).then(response => {
    console.log(response); // => Array<number>[50]
}).catch(error => {
    console.log(error);
});

Generating Random String

random.generateStrings(10, 5).then(response => {
    console.log(response); // => Array<string[5]>[10]
}).catch(error => {
    console.log(error);
});

Getting Quota

random.getQuota().then(response => {
    console.log(response); // => 1000000 (If you have not generated anything yet)
}).catch(error => {
    console.log(error);
});

API

generateInteger(min, max, amount, format)

Generates true random integers within a user-defined range

  • Parameters:
    • minnumber — The smallest value allowed for each integer.
    • maxnumber — The largest value allowed for each integer.
    • amountnumber[optional] — The number of integers requested.
    • formatstring[optional] — The format that will be used to print the numbers, i.e., binary, octal, decimal or hexadecimal.
  • Returns: Promise<Array<number>> — Promise Array of number.

generateIntegerSequences(min, max)

Generates uniform or multiform sequences of true random integers within user-defined ranges.

  • Parameters:
    • minnumber — The lower bound of the interval (inclusive).
    • maxnumber — The upper bound of the interval (inclusive).
  • Returns: Promise<Array<number>> — Promise Array of number.

generateStrings(amount, length, enableNumber?, enableUppercase?, enableLowercase?, enableUnique?)

Generates true random strings.

  • Parameters:
    • amountnumber — The number of strings requested.
    • lengthnumber — The length of the strings. All the strings produced will have the same length.
    • enableNumbeeboolean[optional: true] — Determines whether digits (0-9) are allowed to occur in the strings.
    • enableUppercaseboolean[optional: true] — Determines whether uppercase alphabetic characters (A-Z) are allowed to occur in the strings.
    • enableLowercaseboolean[optional]: true — Determines lowercase alphabetic characters (a-z) are allowed to occur in the strings.
    • enableUniqueboolean[optional: true] — Determines whether the strings picked should be unique (as a series of raffle tickets drawn from a hat) or not (as a series of die rolls).
  • Returns: Promise<Array<string>> — Promise Array of String.

getQuota()

This allows you to examine your quota at any point in time. The quota system works on the basis of IP addresses. Each IP address has a base quota of 1,000,000 bits. When your client makes a request for random numbers (or strings, etc.), the server deducts the number of bits it took to satisfy your request from the quota associated with your client's IP address.

  • Returns: Promise<number> — Promise Number