# java-util-random

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

Latest version **1.0.2** (published 2023-09-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install java-util-random
pnpm add java-util-random
yarn add java-util-random
bun add java-util-random
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2023-09-21 |
| First published | 2020-11-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 32.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | BluSpring |
| Maintainers | bluspring |

## Links

- npm: https://www.npmjs.com/package/java-util-random
- Repository: https://github.com/BluSpring/java-util-random
- Homepage: https://github.com/BluSpring/java-util-random#readme
- Issues: https://github.com/BluSpring/java-util-random/issues
- npm.io page: https://npm.io/package/java-util-random

## Recent versions

- 1.0.2 (latest) — 2023-09-21
- 1.0.1 — 2022-08-01
- 1.0.0 — 2020-11-02

## README

# java-util-random
[![npm version](https://badge.fury.io/js/java-util-random.svg)](https://badge.fury.io/js/java-util-random)

A recreation of Java's java.util.Random class in Node.js.

Yes, I know there's already [java-random](https://npmjs.com/package/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](https://github.com/BluSpring/java-util-random/issues/new)!

## 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:
---
```js
const Random = require('java-util-random').default;
const random = new Random();
```
TypeScript
---
```ts
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.

---
_Source: https://npm.io/package/java-util-random · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
