Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ml-random

Package Overview
Dependencies
Maintainers
5
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ml-random - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

5

History.md

@@ -0,1 +1,6 @@

<a name="0.2.0"></a>
# [0.2.0](https://github.com/mljs/random/compare/v0.1.0...v0.2.0) (2018-05-16)
<a name="0.1.0"></a>

@@ -2,0 +7,0 @@ # 0.1.0 (2018-05-16)

11

lib-es6/index.js

@@ -14,6 +14,6 @@ // tslint:disable-next-line

const xsadd = new XSAdd(seedOrRandom);
this.random = xsadd.random;
this.randomGenerator = xsadd.random;
}
else {
this.random = seedOrRandom;
this.randomGenerator = seedOrRandom;
}

@@ -23,6 +23,9 @@ }

if (typeof values === 'number') {
return choice(values, options, this.random);
return choice(values, options, this.randomGenerator);
}
return choice(values, options, this.random);
return choice(values, options, this.randomGenerator);
}
random() {
return this.randomGenerator();
}
}

@@ -7,3 +7,3 @@ import { IChoiceOptions } from './Options';

export default class Random {
private random;
private randomGenerator;
/**

@@ -21,2 +21,3 @@ * @param [seedOrRandom=Math.random] - Control the random number generator used by the Random class instance. Pass a random number generator function with a uniform distribution over the half-open interval [0, 1[. If seed will pass it to ml-xsadd to create a seeded random number generator. If undefined will use Math.random.

choice(values: number, options?: IChoiceOptions): number[];
random(): number;
}

@@ -16,6 +16,6 @@ "use strict";

const xsadd = new XSAdd(seedOrRandom);
this.random = xsadd.random;
this.randomGenerator = xsadd.random;
}
else {
this.random = seedOrRandom;
this.randomGenerator = seedOrRandom;
}

@@ -25,7 +25,10 @@ }

if (typeof values === 'number') {
return choice_1.default(values, options, this.random);
return choice_1.default(values, options, this.randomGenerator);
}
return choice_1.default(values, options, this.random);
return choice_1.default(values, options, this.randomGenerator);
}
random() {
return this.randomGenerator();
}
}
exports.default = Random;
{
"name": "ml-random",
"version": "0.1.0",
"version": "0.2.0",
"description": "choose randomly from a selection of elements",

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

"files": ["lib", "lib-es6", "src"],
"types": "lib/index.d.ts",
"scripts": {

@@ -10,0 +11,0 @@ "clean": "shx rm -rf lib-es6 lib",

@@ -5,3 +5,3 @@ import * as XSAdd from 'ml-xsadd';

let random: Random;
describe('test random', () => {
describe('random.choice', () => {
beforeEach(() => {

@@ -55,1 +55,12 @@ random = new Random(28);

});
describe('random.random', () => {
it('should generate random numbers', () => {
random = new Random(14);
const r = [];
for (let i = 0; i < 10; i++) {
r.push(random.random());
}
expect(r).toMatchSnapshot();
});
});

@@ -11,3 +11,3 @@ // tslint:disable-next-line

export default class Random {
private random: IRandomGenerator;
private randomGenerator: IRandomGenerator;
/**

@@ -19,5 +19,5 @@ * @param [seedOrRandom=Math.random] - Control the random number generator used by the Random class instance. Pass a random number generator function with a uniform distribution over the half-open interval [0, 1[. If seed will pass it to ml-xsadd to create a seeded random number generator. If undefined will use Math.random.

const xsadd: any = new XSAdd(seedOrRandom);
this.random = xsadd.random;
this.randomGenerator = xsadd.random;
} else {
this.random = seedOrRandom;
this.randomGenerator = seedOrRandom;
}

@@ -40,6 +40,10 @@ }

if (typeof values === 'number') {
return choice(values, options, this.random);
return choice(values, options, this.randomGenerator);
}
return choice(values, options, this.random);
return choice(values, options, this.randomGenerator);
}
public random(): number {
return this.randomGenerator();
}
}

Sorry, the diff of this file is not supported yet

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