You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

number-generator

Package Overview
Dependencies
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

number-generator - npm Package Compare versions

Comparing version

to
4.0.4

14

CHANGELOG.md

@@ -5,2 +5,16 @@ # Changelog

### [4.0.4](https://github.com/MartinHelmut/number-generator/compare/v4.0.2...v4.0.4) (2020-03-19)
### Bug Fixes
* use prepare script in package.json to check for package manager ([5d1fd5a](https://github.com/MartinHelmut/number-generator/commit/5d1fd5ad052faa79526c396333bc6028b9e7e7f0)), closes [#591](https://github.com/MartinHelmut/number-generator/issues/591)
### [4.0.3](https://github.com/MartinHelmut/number-generator/compare/v4.0.2...v4.0.3) (2020-03-19)
### Bug Fixes
* use prepare script in package.json to check for package manager ([5d1fd5a](https://github.com/MartinHelmut/number-generator/commit/5d1fd5ad052faa79526c396333bc6028b9e7e7f0)), closes [#591](https://github.com/MartinHelmut/number-generator/issues/591)
### [4.0.2](https://github.com/MartinHelmut/number-generator/compare/v4.0.1...v4.0.2) (2020-03-07)

@@ -7,0 +21,0 @@

31

package.json
{
"name": "number-generator",
"version": "4.0.2",
"version": "4.0.4",
"description": "Generate repeatable pseudo random numbers and non-cryptographic hash numbers for usage in Node.js and browser environments.",

@@ -13,3 +13,2 @@ "main": "lib/index.js",

"build": "rollup -c rollup.config.js",
"build:docs": "jsdoc -c jsdoc.config.js --verbose",
"build:reference:code": "./scripts/generate-reference.sh",

@@ -23,10 +22,8 @@ "build:tests": "rollup -c rollup-tests.config.js",

"lint": "eslint --ignore-path .prettierignore ./",
"preinstall": "node ./scripts/ensure-package-manager.js",
"prepare": "pnpm run ci",
"prerelease": "pnpm run ci",
"release": "standard-version -a",
"start:docs": "pnpm run build:docs && serve ./docs",
"docs": "jsdoc -c jsdoc.config.js --verbose && serve ./docs",
"test": "nyc mocha --require @babel/register src/__tests__/*.test.js src/**/__tests__/*.test.js",
"test:benchmark": "node --require @babel/register src/__tests__/murmur.benchmark.js && node --require @babel/register src/__tests__/alea.benchmark.js",
"test:prod": "pnpm run build && cross-env NODE_ENV=production nyc mocha --require @babel/register src/**/__tests__/*.js && mocha --require ts-node/register src/**/*.test.ts",
"test:prod": "pnpm run build && NODE_ENV=production nyc mocha --require @babel/register src/**/__tests__/*.js && mocha --require ts-node/register src/**/*.test.ts",
"test:treeshaking": "agadoo lib/index.esm.js"

@@ -65,3 +62,3 @@ },

"IE >= 10",
"maintained node versions"
"node >= 8"
],

@@ -129,9 +126,10 @@ "eslintConfig": {

"@babel/register": "7.8.6",
"@types/chai": "4.2.10",
"@rollup/plugin-node-resolve": "7.1.1",
"@rollup/plugin-replace": "2.3.1",
"@types/chai": "4.2.11",
"@types/mocha": "7.0.2",
"@types/node": "12.12.29",
"@types/node": "12.12.30",
"agadoo": "2.0.0",
"benchmark": "2.1.4",
"chai": "4.2.0",
"chalk": "3.0.0",
"commitizen": "4.0.3",

@@ -141,4 +139,2 @@ "conventional-changelog": "3.1.18",

"coveralls": "3.0.9",
"cpy": "8.1.0",
"cross-env": "7.0.2",
"cz-conventional-changelog": "3.1.0",

@@ -148,7 +144,6 @@ "eslint": "6.8.0",

"jsdoc": "3.6.3",
"mocha": "7.1.0",
"mocha": "7.1.1",
"nyc": "15.0.0",
"prettier": "1.19.1",
"regenerator-runtime": "0.13.3",
"rollup": "2.0.2",
"rollup": "2.1.0",
"rollup-plugin-babel": "4.4.0",

@@ -160,10 +155,8 @@ "rollup-plugin-clear": "2.0.7",

"rollup-plugin-node-builtins": "2.1.2",
"rollup-plugin-node-resolve": "5.2.0",
"rollup-plugin-replace": "2.2.0",
"rollup-plugin-terser": "5.2.0",
"rollup-plugin-terser": "5.3.0",
"serve": "11.3.0",
"standard-version": "7.1.0",
"ts-node": "8.6.2",
"ts-node": "8.7.0",
"typescript": "3.8.3"
}
}

@@ -10,3 +10,3 @@ # Number Generator

Generate repeatable pseudo random numbers and non-cryptographic hash numbers for usage in Node.js and browser environments.
Generate repeatable pseudo random numbers and non-cryptographic hash numbers for usage in Node.js (>= 8) and browser environments (major browsers and IE >= 10).

@@ -23,4 +23,3 @@ ## Contents

- [Change the seed](#change-the-seed)
- [Get the state](#get-the-state)
- [Set the state](#set-the-state)
- [Get and restore the state](#get-and-restore-the-state)
- [Something like Math.random?](#something-like-mathrandom)

@@ -63,3 +62,3 @@ - [Murmur hash](#murmur-hash)

# pnpm
pnpm install number-generator
pnpm add number-generator
```

@@ -116,7 +115,7 @@

**Attention:** The default seed `1` should not be used! It produces one duplicate at 4370 calls. This can be avoided by using a seed larger or equal to 2.
⚠️ **Attention:** The default seed `1` should not be used! It produces one duplicate at 4370 calls. This can be avoided by using a seed larger or equal to 2. Nevertheless, this is still included in the library to not break applications using the default behavior.
#### Create a new random number generator
First step is to [include the library](#install) functions you want to use in your application. If you only want to use the Alea implementation you can import it directly by:
First step is to [include the library](#install) functions you want to use in your application. If you only want to use the Alea implementation you can import it directly:

@@ -127,3 +126,3 @@ ```javascript

Now you can create a new generator by calling the function with a seed **equal or larger to 2**. The number `0`, float or negative numbers are not valid and will throw a `TypeError`.
Now you can create a new generator by calling the function with a seed **equal or larger to 2**. The number `0`, float or negative numbers are not valid and will throw a `TypeError`. See the remark [at the beginning of this section](#random-numbers) on why to avoid 1 as a seed.

@@ -151,3 +150,3 @@ ```javascript

This will create the exact **same result on your machine**! You get always the same values for the same seed used.
This will create the exact **same result on your machine**! You will always get the same value for the same seed.

@@ -168,3 +167,3 @@ This means if you create multiple generators with the same seed, you get the same result for the n-th call:

The same that works for [the uInt32 method](#create-an-unsigned-integer) applies to the `uFloat32` method. But this time you get an unsigned float.
The same that works for [the uInt32 method](#create-an-unsigned-integer) applies to the `uFloat32` method, but this time you get an unsigned float.

@@ -177,3 +176,3 @@ ```javascript

Again, this should create the exact **same result on your machine**!
Again, this will create the exact **same result on your machine**!

@@ -211,3 +210,3 @@ If you create multiple generators with the same seed, you get the same result for the n-th call:

#### Get the state
#### Get and restore the state

@@ -241,4 +240,2 @@ You can get and restore the internal state with `getState` and `setState`.

#### Set the state
You can set the state with `setState` on two ways. Either you don't pass any parameter to the state function, where it will reset the state to the initial state. Or you can pass a state object to restore a previous state:

@@ -259,3 +256,3 @@

If you want something similar to `Math.random()` (without duplicate values) you can use the [JavaScript Date API][date] with a timestamp and combine it with the `uFloat32` method from the `aleaRNGFactory` e.g.:
If you want something similar to `Math.random()` (without generating duplicated values) you can use the [JavaScript Date API][date] with a timestamp and combine it with the `uFloat32` method from the `aleaRNGFactory` e.g.:

@@ -271,3 +268,3 @@ ```javascript

To generate a hash there are four functions, `murmurhash2_x86_32`, `murmurhash3_x86_32`, `murmurhash3_x86_128` and `murmurhash3_x64_128`. The `murmurhash` functions implement the [MurmurHash algorithm for 32 and 128 bit][mur] in JavaScript (murmurhash2 and 3) for x86 and x64. They take a string and generate a non-cryptographic hash number as unsigned integer with 32 bit or a string hash with 128 bit.
To generate a hash there are four functions, `murmurhash2_x86_32`, `murmurhash3_x86_32`, `murmurhash3_x86_128` and `murmurhash3_x64_128`. The "murmur hash" functions implement the [MurmurHash algorithm for 32 and 128 bit][mur] in JavaScript (murmurhash2 and 3) for x86 and x64. They take a string and generate a non-cryptographic hash number as unsigned integer with 32 bit or a string hash with 128 bit.

@@ -354,4 +351,2 @@ You can import the functions directly:

Exceptions for Node are versions that reached the End-of-Life as defined under https://github.com/nodejs/Release#end-of-life-releases.
### Benchmarks

@@ -358,0 +353,0 @@