Distance
Distance<
T> =Callable<[T,T],number>
Defined in: packages/core/src/function/compare/types.ts:41
How far apart a and b are.
Must be a true metric: non-negative, symmetric, 0 exactly when the two are
equivalent, and satisfying the triangle inequality. Metric-space indexes
prune entire subtrees on the strength of that last property, so a distance
that violates it makes their results wrong, not merely slower.
Not a Comparator: it answers how far apart, never which comes first.
To order candidates by closeness to a query, derive one —
createComparatorBy((item) => distance(query, item)).
Type Parameters
Section titled “Type Parameters”T