New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

java-util-random

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

java-util-random

A recreation of Java's java.util.Random, with full support for BigInts. Streams not supported yet.

latest
Source
npmnpm
Version
1.0.2
Version published
Weekly downloads
65
91.18%
Maintainers
1
Weekly downloads
 
Created
Source

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.

FAQs

Package last updated on 21 Sep 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts