@kourge/ordering - v2.0.0-rc.0 › "scoring"
Defines the Scoring interface, a simpler alternative to the
Comparator interface.
▸ 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<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›