Skip to content

createBisector

createBisector<T, V>(valueOf): Bisector<T, V>

Defined in: ordered/create-bisector.ts:35

Builds a Bisector that locates value among items by comparing valueOf(item) instead of item itself, in ascending natural order (</>) — so items can be sorted by any derived key, not just T’s own order.

valueOf is called once per comparison during each search, not once per item up front — binary search stays O(log n), it never materialises a mapped array.

center is exposed only for a numeric key, since “nearest” needs a distance and no distance can be derived from an arbitrary ordering.

T

V

Callable<[T], V>

Extracts the sort key from an item.

Bisector<T, V>

Bound left and right bisect functions, plus center for a numeric key.