Comparing version 1.0.0 to 1.0.1
import { ChoiceOptions } from './Options'; | ||
import IRandomGenerator from './RandomGenerator'; | ||
declare function randomChoice<T>(values: T[], options?: ChoiceOptions, random?: IRandomGenerator): T[]; | ||
declare function randomChoice(values: number, options?: ChoiceOptions, random?: IRandomGenerator): number[]; | ||
import { RandomNumberGenerator } from './RandomNumberGenerator'; | ||
declare function randomChoice<T>(values: T[], options?: ChoiceOptions, random?: RandomNumberGenerator): T[]; | ||
declare function randomChoice(values: number, options?: ChoiceOptions, random?: RandomNumberGenerator): number[]; | ||
export default randomChoice; | ||
//# sourceMappingURL=choice.d.ts.map |
import { ChoiceOptions } from './Options'; | ||
import IRandomGenerator from './RandomGenerator'; | ||
import { RandomNumberGenerator } from './RandomNumberGenerator'; | ||
/** | ||
@@ -11,3 +11,3 @@ * @classdesc Random class | ||
*/ | ||
constructor(seedOrRandom?: IRandomGenerator | number); | ||
constructor(seedOrRandom?: RandomNumberGenerator | number); | ||
/** | ||
@@ -40,2 +40,3 @@ * Returns an array of elements choosen from a list | ||
export * from './Options'; | ||
export * from './RandomNumberGenerator'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -58,2 +58,3 @@ import XSAdd from 'ml-xsadd'; | ||
export * from './Options'; | ||
export * from './RandomNumberGenerator'; | ||
//# sourceMappingURL=index.js.map |
import { ChoiceOptions } from './Options'; | ||
import IRandomGenerator from './RandomGenerator'; | ||
declare function randomChoice<T>(values: T[], options?: ChoiceOptions, random?: IRandomGenerator): T[]; | ||
declare function randomChoice(values: number, options?: ChoiceOptions, random?: IRandomGenerator): number[]; | ||
import { RandomNumberGenerator } from './RandomNumberGenerator'; | ||
declare function randomChoice<T>(values: T[], options?: ChoiceOptions, random?: RandomNumberGenerator): T[]; | ||
declare function randomChoice(values: number, options?: ChoiceOptions, random?: RandomNumberGenerator): number[]; | ||
export default randomChoice; | ||
//# sourceMappingURL=choice.d.ts.map |
import { ChoiceOptions } from './Options'; | ||
import IRandomGenerator from './RandomGenerator'; | ||
import { RandomNumberGenerator } from './RandomNumberGenerator'; | ||
/** | ||
@@ -11,3 +11,3 @@ * @classdesc Random class | ||
*/ | ||
constructor(seedOrRandom?: IRandomGenerator | number); | ||
constructor(seedOrRandom?: RandomNumberGenerator | number); | ||
/** | ||
@@ -40,2 +40,3 @@ * Returns an array of elements choosen from a list | ||
export * from './Options'; | ||
export * from './RandomNumberGenerator'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -78,2 +78,3 @@ "use strict"; | ||
__exportStar(require("./Options"), exports); | ||
__exportStar(require("./RandomNumberGenerator"), exports); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "ml-random", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Choose randomly from a selection of elements", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
import { ChoiceOptions } from './Options'; | ||
import IRandomGenerator from './RandomGenerator'; | ||
import { RandomNumberGenerator } from './RandomNumberGenerator'; | ||
@@ -9,3 +9,3 @@ const PROB_TOLERANCE = 0.00000001; | ||
options?: ChoiceOptions, | ||
random?: IRandomGenerator, | ||
random?: RandomNumberGenerator, | ||
): T[]; | ||
@@ -15,3 +15,3 @@ function randomChoice( | ||
options?: ChoiceOptions, | ||
random?: IRandomGenerator, | ||
random?: RandomNumberGenerator, | ||
): number[]; | ||
@@ -21,3 +21,3 @@ function randomChoice<T>( | ||
options: ChoiceOptions = {}, | ||
random: IRandomGenerator = Math.random, | ||
random: RandomNumberGenerator = Math.random, | ||
): Array<T | number> { | ||
@@ -84,3 +84,3 @@ const { size = 1, replace = false, probabilities } = options; | ||
n: number, | ||
random: IRandomGenerator, | ||
random: RandomNumberGenerator, | ||
cumSum: number[] | undefined, | ||
@@ -87,0 +87,0 @@ ) { |
import XSAdd from 'ml-xsadd'; | ||
import { ChoiceOptions } from './Options'; | ||
import IRandomGenerator from './RandomGenerator'; | ||
import { RandomNumberGenerator } from './RandomNumberGenerator'; | ||
import choice from './choice'; | ||
@@ -11,7 +11,7 @@ | ||
export default class Random { | ||
private randomGenerator: IRandomGenerator; | ||
private randomGenerator: RandomNumberGenerator; | ||
/** | ||
* @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. | ||
*/ | ||
constructor(seedOrRandom: IRandomGenerator | number = Math.random) { | ||
constructor(seedOrRandom: RandomNumberGenerator | number = Math.random) { | ||
if (typeof seedOrRandom === 'number') { | ||
@@ -80,1 +80,2 @@ const xsadd = new XSAdd(seedOrRandom); | ||
export * from './Options'; | ||
export * from './RandomNumberGenerator'; |
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 not supported yet
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 not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
39278
692
0