Skip to content

pactole-js


Class: EuroMillionsCombination

Defined in: combinations/euromillions-combination.ts:68

Preconfigured EuroMillions lottery combination.

The constructor accepts an options object with optional numbers and stars fields. It also supports passing a flattened array where the star values immediately follow the main numbers; when stars is omitted the first 5 elements are treated as main values and the following 2 as stars.

Param

main numbers, a rank, another EuroMillionsCombination (copy semantics), or an iterable that may include stars when stars is omitted.

Param

star numbers or a rank; if null and numbers is an iterable the trailing elements are treated as stars.

Example

const comb = new EuroMillionsCombination({ numbers: [3, 5, 12, 23, 44], stars: [2, 9] });
comb.numbers.toString();
comb.stars.toString();

Extends

Constructors

Constructor

new EuroMillionsCombination(__namedParameters?): EuroMillionsCombination

Defined in: combinations/euromillions-combination.ts:72

Parameters

__namedParameters?

EuroMillionsCombinationOptions = {}

Returns

EuroMillionsCombination

Overrides

LotteryCombination.constructor

Properties

numbers

readonly numbers: BoundCombination

Defined in: combinations/euromillions-combination.ts:69


stars

readonly stars: BoundCombination

Defined in: combinations/euromillions-combination.ts:70

Accessors

combinations

Get Signature

get combinations(): number

Defined in: combinations/lottery-combination.ts:217

Get total number of possible combinations.

Example
new LotteryCombination().combinations; // 0
Returns

number

Product of component combinations or 0 for empty lottery.

Inherited from

LotteryCombination.combinations


components

Get Signature

get components(): CombinationComponents

Defined in: combinations/lottery-combination.ts:135

Get a copy of component mapping.

Example
const lottery = new LotteryCombination({ components: { numbers: new BoundCombination([1, 2, 3], { start: 1, end: 50, count: 5 }) } });
Object.keys(lottery.components); // ['numbers']
Returns

CombinationComponents

Shallow copy of component map.

Inherited from

LotteryCombination.components


count

Get Signature

get count(): number

Defined in: combinations/lottery-combination.ts:205

Get configured component total count.

Example
const numbers = new BoundCombination(null, null, 1, 50, 5);
const stars = new BoundCombination(null, null, 1, 12, 2);
new LotteryCombination({ components: { numbers, stars } }).count; // 7
Returns

number

Sum of configured component counts.

Inherited from

LotteryCombination.count


length

Get Signature

get length(): number

Defined in: combinations/lottery-combination.ts:191

Get flattened value length.

Example
const numbers = new BoundCombination([1, 2, 3, 4, 5], null, 1, 50, 5);
const stars = new BoundCombination([1, 2], null, 1, 12, 2);
new LotteryCombination({ components: { numbers, stars } }).length; // 7
Returns

number

Number of selected values across components.

Inherited from

LotteryCombination.length


maxWinningRank

Get Signature

get maxWinningRank(): number | null

Defined in: combinations/lottery-combination.ts:281

Get maximum winning rank.

Example
new LotteryCombination({ winningRanks: { '5,2': 1, '4,2': 4 } }).maxWinningRank; // 4
Returns

number | null

Maximum winning rank or null.

Inherited from

LotteryCombination.maxWinningRank


minWinningRank

Get Signature

get minWinningRank(): number | null

Defined in: combinations/lottery-combination.ts:264

Get minimum winning rank.

Example
new LotteryCombination({ winningRanks: { '5,2': 1, '4,2': 4 } }).minWinningRank; // 1
Returns

number | null

Minimum winning rank or null.

Inherited from

LotteryCombination.minWinningRank


nbWinningRanks

Get Signature

get nbWinningRanks(): number

Defined in: combinations/lottery-combination.ts:247

Get winning-rank span length.

Example
new LotteryCombination({ winningRanks: { '5,2': 1, '4,2': 4 } }).nbWinningRanks; // 4
Returns

number

Span length between min and max rank values (inclusive).

Inherited from

LotteryCombination.nbWinningRanks


rank

Get Signature

get rank(): number

Defined in: combinations/lottery-combination.ts:163

Get mixed rank of all components.

Example
const numbers = new BoundCombination([1, 2, 3, 4, 5], null, 1, 50, 5);
const stars = new BoundCombination([1, 2], null, 1, 12, 2);
new LotteryCombination({ components: { numbers, stars } }).rank;
Returns

number

Combined rank.

Inherited from

LotteryCombination.rank


values

Get Signature

get values(): CombinationValues

Defined in: combinations/lottery-combination.ts:149

Get flattened values of all components in declaration order.

Example
const numbers = new BoundCombination([1, 2, 3, 4, 5], null, 1, 50, 5);
const stars = new BoundCombination([1, 2], null, 1, 12, 2);
new LotteryCombination({ components: { numbers, stars } }).values; // [1, 2, 3, 4, 5, 1, 2]
Returns

CombinationValues

Flattened values.

Inherited from

LotteryCombination.values


winningRanks

Get Signature

get winningRanks(): CombinationWinningRanks

Defined in: combinations/lottery-combination.ts:235

Get a copy of winning-rank mapping.

Example
const lottery = new LotteryCombination({ winningRanks: { '5,2': 1 } });
lottery.winningRanks; // { '5,2': 1 }
Returns

CombinationWinningRanks

Winning-rank map copy.

Inherited from

LotteryCombination.winningRanks

Methods

[iterator]()

[iterator](): Iterator\<number>

Defined in: combinations/lottery-combination.ts:792

Returns

Iterator\<number>

Inherited from

LotteryCombination.[iterator]


buildComponents()

protected buildComponents(components): CombinationComponents

Defined in: combinations/lottery-combination.ts:802

Build a mapped CombinationComponents object from a components payload.

Subclasses may override this to customize how provided component inputs are turned into BoundCombination instances.

Parameters

components

Record\<string, CombinationInputOrRank | LotteryCombination>

Returns

CombinationComponents

Inherited from

LotteryCombination.buildComponents


compares()

compares(combination?): number

Defined in: combinations/lottery-combination.ts:642

Compare with another input.

Parameters

combination?

LotteryCombinationMatchOptions = {}

Optional rank/values/combination source.

Returns

number

-1, 0, or 1.

Throws

Thrown when an unknown component name is provided.

Example

const numbers = new BoundCombination([1, 2, 3, 4, 5], null, 1, 50, 5);
const lottery = new LotteryCombination({ components: { numbers } });
lottery.compares({ combination: [1, 2, 3, 4, 6] }); // -1

Inherited from

LotteryCombination.compares


copy()

copy(winningRanks?): this

Defined in: combinations/lottery-combination.ts:353

Copy this combination with optional overrides.

Parameters

winningRanks?

LotteryCombinationCopyOptions = {}

Optional replacement winning-rank map.

Returns

this

New lottery combination.

Example

const numbers = new BoundCombination({ values: [1, 2, 3, 4, 5], start: 1, end: 50, count: 5 });
const base = new LotteryCombination({ winningRanks: { '5': 1 }, components: { numbers } });
base.copy({ winningRanks: { '4': 2 } }).winningRanks; // { '4': 2 }

Inherited from

LotteryCombination.copy


createCombination()

protected createCombination(components, _winningRanks): this

Defined in: combinations/euromillions-combination.ts:112

Create a new LotteryCombination instance. Made protected so subclasses can override instance creation behavior while reusing buildComponents.

Parameters

components

Record\<string, CombinationInputOrRank | LotteryCombination>

_winningRanks

CombinationWinningRanks | null

Returns

this

Overrides

LotteryCombination.createCombination


equals()

equals(combination?): boolean

Defined in: combinations/lottery-combination.ts:515

Test equality with another input.

Parameters

combination?

LotteryCombinationMatchOptions = {}

Optional rank/values/combination source.

Returns

boolean

true when fully equal.

Throws

Thrown when an unknown component name is provided.

Example

const numbers = new BoundCombination([1, 2, 3, 4, 5], null, 1, 50, 5);
const a = new LotteryCombination({ components: { numbers } });
const b = a.copy();
a.equals(b); // true

Inherited from

LotteryCombination.equals


generate()

generate(n?): EuroMillionsCombination[]

Defined in: combinations/lottery-combination.ts:334

Generate random combinations with the same component schema.

Parameters

n?

LotteryCombinationGenerateOptions = {}

Number of combinations to generate.

Returns

EuroMillionsCombination[]

Generated combinations.

Example

const numbers = new BoundCombination(null, { start: 1, end: 50, count: 5 });
const stars = new BoundCombination(null, { start: 1, end: 12, count: 2 });
new LotteryCombination({ components: { numbers, stars } }).generate({ n: 2 }).length; // 2

Inherited from

LotteryCombination.generate


get()

get(index): number

Defined in: combinations/lottery-combination.ts:733

Get a value by flattened index.

Parameters

index

number

Zero-based flattened index.

Returns

number

Flattened value at index.

Throws

Thrown when index is out of bounds.

Inherited from

LotteryCombination.get


getCombination()

getCombination(combination?): this

Defined in: combinations/lottery-combination.ts:379

Build a combination from rank, values, or another lottery combination.

Parameters

combination?

LotteryCombinationBuildOptions = {}

Optional rank/values/combination source.

Returns

this

Constructed lottery combination.

Throws

Thrown when an unknown component name is provided.

Example

const numbers = new BoundCombination({ start: 1, end: 50, count: 5 });
const stars = new BoundCombination({ start: 1, end: 12, count: 2 });
const lottery = new LotteryCombination({ components: { numbers, stars } });
lottery.getCombination({ combination: [1, 2, 3, 4, 5, 1, 2] }).values; // [1, 2, 3, 4, 5, 1, 2]

Inherited from

LotteryCombination.getCombination


getComponent()

getComponent(name): BoundCombination | null

Defined in: combinations/lottery-combination.ts:462

Get a component by name.

Parameters

name

string

Component name.

Returns

BoundCombination | null

Component or null.

Example

const lottery = new LotteryCombination({ components: { numbers: new BoundCombination(null, { start: 1, end: 50, count: 5 }) } });
lottery.getComponent('numbers'); // BoundCombination
lottery.getComponent('stars'); // null

Inherited from

LotteryCombination.getComponent


getComponents()

getComponents(components?): CombinationComponents

Defined in: combinations/lottery-combination.ts:436

Build updated components for known component names.

Parameters

components?

Record\<string, CombinationInputOrRank | LotteryCombination> = {}

Component update payload.

Returns

CombinationComponents

Built component map.

Throws

Thrown when an unknown component name is provided.

Example

const numbers = new BoundCombination(null, { start: 1, end: 50, count: 5 });
const lottery = new LotteryCombination({ components: { numbers } });
lottery.getComponents({ numbers: [1, 2, 3, 4, 5] }).numbers.values;

Inherited from

LotteryCombination.getComponents


getComponentValues()

getComponentValues(name): CombinationValues

Defined in: combinations/lottery-combination.ts:476

Get values for a specific component.

Parameters

name

string

Component name.

Returns

CombinationValues

Component values or empty array.

Example

const lottery = new LotteryCombination({ components: { numbers: new BoundCombination([1, 2, 3, 4, 5], { start: 1, end: 50, count: 5 }) } });
lottery.getComponentValues('numbers'); // [1, 2, 3, 4, 5]

Inherited from

LotteryCombination.getComponentValues


getWinningRank()

getWinningRank(combination?): number | null

Defined in: combinations/lottery-combination.ts:495

Get winning rank against a candidate winning combination.

Parameters

combination?

LotteryCombinationMatchOptions = {}

Optional rank/values/combination source.

Returns

number | null

Winning rank or null when unmatched.

Throws

Thrown when an unknown component name is provided.

Example

const ranks = createWinningRanks([[[5, 2], 1]]);
const numbers = new BoundCombination([1, 2, 3, 4, 5], null, 1, 50, 5);
const stars = new BoundCombination([1, 2], null, 1, 12, 2);
const lottery = new LotteryCombination({ winningRanks: ranks, components: { numbers, stars } });
lottery.getWinningRank({ combination: [1, 2, 3, 4, 5, 1, 2] }); // 1

Inherited from

LotteryCombination.getWinningRank


has()

has(value): boolean

Defined in: combinations/lottery-combination.ts:752

Check scalar containment in flattened values.

Parameters

value

number

Candidate value.

Returns

boolean

true when value is present.

Example

const numbers = new BoundCombination([1, 2, 3, 4, 5], null, 1, 50, 5);
new LotteryCombination({ components: { numbers } }).has(3); // true

Inherited from

LotteryCombination.has


hashCode()

hashCode(): number

Defined in: combinations/lottery-combination.ts:765

Get integer hash representation.

Returns

number

Rank-based hash.

Example

const numbers = new BoundCombination([1, 2, 3, 4, 5], null, 1, 50, 5);
new LotteryCombination({ components: { numbers } }).hashCode();

Inherited from

LotteryCombination.hashCode


includes()

includes(combination?): boolean

Defined in: combinations/lottery-combination.ts:552

Test inclusion of another input.

Parameters

combination?

LotteryCombinationIncludesOptions = {}

Optional scalar/rank/values/combination source.

Returns

boolean

true when the candidate is included.

Throws

Thrown when an unknown component name is provided.

Example

const numbers = new BoundCombination([1, 2, 3, 4, 5], null, 1, 50, 5);
const lottery = new LotteryCombination({ components: { numbers } });
lottery.includes({ combination: 3 }); // true

Inherited from

LotteryCombination.includes


intersection()

intersection(combination?): LotteryCombination

Defined in: combinations/lottery-combination.ts:609

Get intersection with another input.

Parameters

combination?

LotteryCombinationMatchOptions = {}

Optional rank/values/combination source.

Returns

LotteryCombination

Intersection lottery combination.

Throws

Thrown when an unknown component name is provided.

Example

const numbers = new BoundCombination([1, 2, 3, 4, 5], null, 1, 50, 5);
const lottery = new LotteryCombination({ components: { numbers } });
lottery.intersection({ combination: [4, 5] }).values; // [4, 5]

Inherited from

LotteryCombination.intersection


intersects()

intersects(combination?): boolean

Defined in: combinations/lottery-combination.ts:584

Test intersection with another input.

Parameters

combination?

LotteryCombinationMatchOptions = {}

Optional rank/values/combination source.

Returns

boolean

true when every provided non-empty component intersects.

Throws

Thrown when an unknown component name is provided.

Example

const numbers = new BoundCombination([1, 2, 3, 4, 5], null, 1, 50, 5);
const lottery = new LotteryCombination({ components: { numbers } });
lottery.intersects({ combination: [5] }); // true

Inherited from

LotteryCombination.intersects


similarity()

similarity(combination?): number

Defined in: combinations/lottery-combination.ts:681

Compute similarity ratio in [0, 1].

Parameters

combination?

LotteryCombinationMatchOptions = {}

Optional rank/values/combination source.

Returns

number

Similarity ratio.

Throws

Thrown when an unknown component name is provided.

Example

const numbers = new BoundCombination([1, 2, 3, 4, 5], null, 1, 50, 5);
const lottery = new LotteryCombination({ components: { numbers } });
lottery.similarity({ combination: [1, 2, 8, 9, 10] }); // 0.4

Inherited from

LotteryCombination.similarity


toRepr()

toRepr(): string

Defined in: combinations/euromillions-combination.ts:130

Return a string representation.

Returns

string

Representation string.

Overrides

LotteryCombination.toRepr


toString()

toString(): string

Defined in: combinations/lottery-combination.ts:786

Returns

string

Inherited from

LotteryCombination.toString


getCombinationFactory()

static getCombinationFactory(combinationFactory): (options?) => LotteryCombination

Defined in: combinations/lottery-combination.ts:303

Normalize a factory input.

Accepts a direct factory function, a template LotteryCombination, or any fallback value (resolved to an empty-default factory).

Parameters

combinationFactory

unknown

Factory-like input.

Returns

Normalized factory function.

(options?): LotteryCombination

Parameters
options?
combination?

CombinationInput | LotteryCombination

components?

Record\<string, CombinationInputOrRank | LotteryCombination>

Returns

LotteryCombination

Example

const factory = LotteryCombination.getCombinationFactory(null);
factory(undefined, { components: {} }); // LotteryCombination

Inherited from

LotteryCombination.getCombinationFactory