New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

pure-rand

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pure-rand - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

lib/esm/distribution/Distribution.d.ts

42

lib/esm/generator/LinearCongruential.js

@@ -5,2 +5,8 @@ var MULTIPLIER = 0x000343fd;

var MASK_2 = (1 << 31) - 1;
var computeNextSeed = function (seed) {
return (seed * MULTIPLIER + INCREMENT) & MASK;
};
var computeValueFromNextSeed = function (nextseed) {
return (nextseed & MASK_2) >> 16;
};
var LinearCongruential = (function () {

@@ -17,4 +23,4 @@ function LinearCongruential(seed) {

LinearCongruential.prototype.next = function () {
var nextseed = (this.seed * MULTIPLIER + INCREMENT) & MASK;
return [(nextseed & MASK_2) >> 16, new LinearCongruential(nextseed)];
var nextseed = computeNextSeed(this.seed);
return [computeValueFromNextSeed(nextseed), new LinearCongruential(nextseed)];
};

@@ -25,5 +31,31 @@ LinearCongruential.min = 0;

}());
export default function (seed) {
var LinearCongruential32 = (function () {
function LinearCongruential32(seed) {
this.seed = seed;
}
LinearCongruential32.prototype.min = function () {
return LinearCongruential32.min;
};
LinearCongruential32.prototype.max = function () {
return LinearCongruential32.max;
};
LinearCongruential32.prototype.next = function () {
var s1 = computeNextSeed(this.seed);
var v1 = computeValueFromNextSeed(s1);
var s2 = computeNextSeed(s1);
var v2 = computeValueFromNextSeed(s2);
var s3 = computeNextSeed(s2);
var v3 = computeValueFromNextSeed(s3);
return [v3 + LinearCongruential32.offset * (v2 + LinearCongruential32.offset * (v1 % 4)), new LinearCongruential32(s3)];
};
LinearCongruential32.offset = Math.pow(2, 15);
LinearCongruential32.min = 0;
LinearCongruential32.max = 0xffffffff;
return LinearCongruential32;
}());
export var congruential = function (seed) {
return new LinearCongruential(seed);
}
;
};
export var congruential32 = function (seed) {
return new LinearCongruential32(seed);
};

4

lib/esm/pure-rand-default.js
import { generateN, skipN } from './generator/RandomGenerator';
import congruential from './generator/LinearCongruential';
import { congruential, congruential32 } from './generator/LinearCongruential';
import mersenne from './generator/MersenneTwister';
import { uniformIntDistribution } from './distribution/UniformDistribution';
export { generateN, skipN, congruential, mersenne, uniformIntDistribution };
export { generateN, skipN, congruential, congruential32, mersenne, uniformIntDistribution };
import { RandomGenerator } from './RandomGenerator';
export default function (seed: number): RandomGenerator;
export declare const congruential: (seed: number) => RandomGenerator;
export declare const congruential32: (seed: number) => RandomGenerator;

@@ -7,2 +7,8 @@ "use strict";

var MASK_2 = (1 << 31) - 1;
var computeNextSeed = function (seed) {
return (seed * MULTIPLIER + INCREMENT) & MASK;
};
var computeValueFromNextSeed = function (nextseed) {
return (nextseed & MASK_2) >> 16;
};
var LinearCongruential = (function () {

@@ -19,4 +25,4 @@ function LinearCongruential(seed) {

LinearCongruential.prototype.next = function () {
var nextseed = (this.seed * MULTIPLIER + INCREMENT) & MASK;
return [(nextseed & MASK_2) >> 16, new LinearCongruential(nextseed)];
var nextseed = computeNextSeed(this.seed);
return [computeValueFromNextSeed(nextseed), new LinearCongruential(nextseed)];
};

@@ -27,6 +33,31 @@ LinearCongruential.min = 0;

}());
function default_1(seed) {
var LinearCongruential32 = (function () {
function LinearCongruential32(seed) {
this.seed = seed;
}
LinearCongruential32.prototype.min = function () {
return LinearCongruential32.min;
};
LinearCongruential32.prototype.max = function () {
return LinearCongruential32.max;
};
LinearCongruential32.prototype.next = function () {
var s1 = computeNextSeed(this.seed);
var v1 = computeValueFromNextSeed(s1);
var s2 = computeNextSeed(s1);
var v2 = computeValueFromNextSeed(s2);
var s3 = computeNextSeed(s2);
var v3 = computeValueFromNextSeed(s3);
return [v3 + LinearCongruential32.offset * (v2 + LinearCongruential32.offset * (v1 % 4)), new LinearCongruential32(s3)];
};
LinearCongruential32.offset = Math.pow(2, 15);
LinearCongruential32.min = 0;
LinearCongruential32.max = 0xffffffff;
return LinearCongruential32;
}());
exports.congruential = function (seed) {
return new LinearCongruential(seed);
}
exports["default"] = default_1;
;
};
exports.congruential32 = function (seed) {
return new LinearCongruential32(seed);
};
import { RandomGenerator, generateN, skipN } from './generator/RandomGenerator';
import congruential from './generator/LinearCongruential';
import { congruential, congruential32 } from './generator/LinearCongruential';
import mersenne from './generator/MersenneTwister';
import Distribution from './distribution/Distribution';
import { uniformIntDistribution } from './distribution/UniformDistribution';
export { RandomGenerator, generateN, skipN, congruential, mersenne, Distribution, uniformIntDistribution };
export { RandomGenerator, generateN, skipN, congruential, congruential32, mersenne, Distribution, uniformIntDistribution };

@@ -7,3 +7,4 @@ "use strict";

var LinearCongruential_1 = require("./generator/LinearCongruential");
exports.congruential = LinearCongruential_1["default"];
exports.congruential = LinearCongruential_1.congruential;
exports.congruential32 = LinearCongruential_1.congruential32;
var MersenneTwister_1 = require("./generator/MersenneTwister");

@@ -10,0 +11,0 @@ exports.mersenne = MersenneTwister_1["default"];

{
"name": "pure-rand",
"version": "1.2.0",
"version": "1.3.0",
"description": " Pure random number generator written in TypeScript",

@@ -10,4 +10,3 @@ "main": "lib/pure-rand.js",

"build": "tsc",
"build:esm": "tsc --module es2015 --outDir lib/esm --declaration false",
"webbuild": "browserify lib/pure-rand.js --s prand -o lib/bundle.js",
"build:esm": "tsc --module es2015 --outDir lib/esm --moduleResolution node",
"test": "nyc mocha \"test/**/*.spec.ts\"",

@@ -31,3 +30,2 @@ "perfs": "ts-node perfs/main",

"@types/node": "^10.7.1",
"browserify": "^16.2.2",
"coveralls": "^3.0.2",

@@ -34,0 +32,0 @@ "fast-check": "^1.4.0",

@@ -28,3 +28,6 @@ # pure-rand

```html
<script src="https://cdn.jsdelivr.net/npm/pure-rand/lib/bundle.js"></script>
<script type="module">
import * as prand from "https://unpkg.com/pure-rand/lib/esm/pure-rand.js";
// prand is now available
</script>
```

@@ -35,3 +38,6 @@

```html
<script src="https://cdn.jsdelivr.net/npm/pure-rand@1.0.2/lib/bundle.js"></script>
<script type="module">
import * as prand from "https://unpkg.com/pure-rand@1.2.0/lib/esm/pure-rand.js";
// prand is now available
</script>
```

@@ -89,2 +95,3 @@

- `prand.congruential(seed: number)`: Linear Congruential generator whose values are within the range 0 to 0x7fff
- `prand.congruential32(seed: number)`: Linear Congruential generator whose values are within the range 0 to 0xffffffff

@@ -91,0 +98,0 @@ Some helpers are also provided in order to ease the use of `RandomGenerator` instances:

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc