Skip to content

Latest commit

 

History

History
76 lines (47 loc) · 2.19 KB

File metadata and controls

76 lines (47 loc) · 2.19 KB

@kourge/ordering - v2.0.0-rc.0"scoring"

Module: "scoring"

Defines the Scoring interface, a simpler alternative to the Comparator interface.

Index

Interfaces

Functions

Functions

scoringFromArray

scoringFromArray<Element>(order: Element[]): Scoring‹Element›

Generates a Scoring function from the given array, whose order is used to produce the numeric score. The efficiency of the result scoring function is linear.

The array should contain all possible values under type Element, but in the scenario that the scoring function is called with an unknown value absent from the array, -1 is returned.

Equality comparison is performed with the ===, with the exception that NaN is considered equal to itself.

Type parameters:

Element

Parameters:

Name Type
order Element[]

Returns: Scoring‹Element›


scoringFromArrayUsingMap

scoringFromArrayUsingMap<Element>(order: Element[]): Scoring‹Element›

Generates a Scoring function from the given array, whose order is used to produce the numeric score. The efficiency of the result scoring function is sublinear, but relies on the environment to provide a good implementation of Map.

The array should contain all possible values under type Element, but in the scenario that the scoring function is called with an unknown value absent from the array, -1 is returned.

Equality comparison is performed with the ===, with the exception that NaN is considered equal to itself.

Type parameters:

Element

Parameters:

Name Type
order Element[]

Returns: Scoring‹Element›