Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 4x 4x | import { Entry } from "@benneq/object";
import { Comparator } from "./_types";
/**
* Creates a {@link Comparator} for {@link Entry} keys.
*
* @example
* entryKeyComparator(numberComparator)([1, 0], [0, 0]) => 1
* entryKeyComparator(numberComparator)([1, 0], [1, 0]) => 0
* entryKeyComparator(numberComparator)([0, 0], [1, 0]) => -1
*
* @typeParam K - the {@link Entry} key type
* @typeParam V - the {@link Entry} value type
* @param comparator
* @returns a {@link Comparator} for {@link Entry} keys
*/
export const entryKeyComparator = <K, V>(
comparator: Comparator<K>
): Comparator<Entry<K, V>> => {
return ([keyA], [keyB]) => comparator(keyA, keyB);
};
|