Skip to content

BluSpring/java-util-random

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

java-util-random

npm version

A recreation of Java's java.util.Random class in Node.js.

Yes, I know there's already java-random, however the code is quite old, it doesn't fully support BigInts, and it doesn't have any typings. This library should be able to meet your needs. If you find any bugs, feel free report it on the issue tracker!

Importing the module

This module was written in TypeScript, so importing it in regular JavaScript is going to need a bit of an extra step.

JavaScript:

const Random = require('java-util-random').default;
const random = new Random();

TypeScript

import Random from 'java-util-random';
const random = new Random();

Known Issues

  • .nextFloat() returns a value inaccurate to what Java returns.

    I'm not quite sure how to fix this issue, so if you know how, please feel free to PR. The values of nextFloat() are now mostly accurate to Java floats, however there are occasionally fairly small precision issues.

  • There are no streams.

    I haven't bothered to try implementing them yet, however in the near future I might.

About

A recreation of Java's java.util.Random class in Node.js.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published