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

truerandom.js

v1.0.2

Published

A module to provide truly random numbers in node.js(quantum randomness).

Downloads

3

Readme

TrueRandom.js

NPM

TrueRandom.js is an utility node js library which provides truly random numbers using quantum randomness.

  • True random numbers generated in a lab by Australian National University dilevered hot and fresh for your projects.
  • Numbers generated using measuring quantum fluctuations in a vaccum tube.
  • This is a non chaotic generator unlike other other generators which depends on atmospheric noises or pseudo randomness.

New Features!

  • Generate 'n' numbers of random numbers, directly from the function
  • zero dependencies

Limitations:

  • Required internet connection (Fallback currently in development).
  • Under heavy development. Not battle tested
  • Many features missing.

Installation

TrueRandom.js requires Node.js v4+ to run.

Installing the module .

npm i truerandom.js

An example of how to use TrueRandom.js in your projects.

const tr = require('truerandom.js');

//Generating 2 unint16 numbers
  tr.generate('uint16',2)
  .then(response => {
  //Do whatever with your generated numbers
console.log(response+' -generated 2 uint16 numbers and then joined together');
  })
  .catch(error => {
    // handle error here
  });

  //Generating 'n' digits of random numbers
 tr.digits(20)
  .then(response => {
console.log(response+'-generated 20 digit random number');
  })
  .catch(error => {
    // handle error here
  });


  

Usage

Currently there are 2 functions available to use:

  • generate
  • digits

#generate(type,number,blocksize) (function)

Used to generate 'n' number of a 'type' of random number. The result is a 'promise'. So u must handle it properly using '.then' and catch errors.

Example code:

tr.generate('uint16',2)
  .then(response => {
  //Do whatever with your generated numbers
  })
  .catch(error => {
    // handle error here
  });
Parameters

the generate function takes 3 parameters

  • type : the type of numbers requested
  • number : the number of indivisual numbers requested
  • blocksize :The length of a block. (Only needed for hex16)

type (parameter)

The generate function supports 3 type of numbers

  • uint8 - it returns numbers that range from 0-255
  • uint16 - it returns numbers that range from 0–65535
  • hex16 - it returns hexa decimal numbers that range from 0000–ffff

number (parameter)

Anu (Australian national university) originally sends an array of the 'type' of number you chose(i.e - either uint8,uint16 or hex16). The 'number' parameter is actually the total no. of numbers you want in an array. TrueRandom.js then joins that array and gives you an string of number.

For example- if you use the following code:

tr.generate('uint8',2)
  .then(response => {
  //Do whatever with your generated numbers
  })
  .catch(error => {
    // handle error here
  });

Then the original responce recieved by TrueRandom.js is

[219,172]

TrueRandom.js then further joins the array and returns a string similar to-

219172

Hence the number parameter is actually the length of the array requested which is directly proportional to the no. of digits of the random number gnerated.

Broadly speaking the bigger no. you use in the number parameter the bigger random number will be generated

Limitation

The maximum number you can use in the number parameter is 1024. Hence the number parameter must range from 1–1024

Blocksize (parameter)

This parameter is only necessary when requesting hex16 type of numbers. It is the half length of the hex16 number u need in each array. for example -

tr.generate('hex16',1,10)
  .then(response => {
  //Do whatever with your generated numbers
  })
  .catch(error => {
    // handle error here
  });

will return

fc3eebbbf3f6abade4b1  // size is 20 which is double the given length

while

tr.generate('hex16',1,25)
  .then(response => {
  //Do whatever with your generated numbers
  })
  .catch(error => {
    // handle error here
  });

whill return

8665c4c7a9db220c483136a701c51a1f797bc5ae69a5de75de // size is 50 which is double the given length

digits (digits) (function) !Under development

Used to generate 'n' digits of random numbers. The result is a ‘promise’. So u must handle it properly using ‘.then’ and catch errors.

Example code:

tr.digits(20)
  .then(response => {
  //Do whatever with your generated numbers gives also the number of digits is 2
  })
  .catch(error => {
    // handle error here
  });

Parameters

the digits funcion takes only one parameter

  • Digits:Number of digit of random number to be generated

digits(parameter)

This is the number of digits expected Cnnot excede more than 5124

This project requires contribution, if you are willing to support this project please don't be afraid to leave a message or make a pull request. Quality changes needs to be done in the documentation along with feature addition and testing. I also encourage you to share your projects if you use this module in your projects I would be more than happy to feature them here.

Todos

  • Write MORE Tests
  • Make it less buggy
  • Make it reliable
  • Make demo apps
  • Support fallback for offline usage
  • Add more functions
  • make it a goto module for randomness projecs

Want to show support I can add your personal or company badge in the docs for free.

License

MIT