@metamask/ocap-kernel
Version:
OCap kernel core components
15 lines • 591 B
text/typescript
/**
* Binary search for key position.
*
* I totally can't believe I have to write this in 2025, but the JS Array
* `indexOf` function does exhaustive search (O(n) instead of O(ln(N))) because
* it can't know the array is both sorted and has no undefined elements.
*
* @param arr - A sorted array of strings.
* @param key - The key to search `arr` for.
*
* @returns the index into `arr` of the first key that is greater than
* `key`, or -1 if no such key exists.
*/
export declare function keySearch(arr: string[], key: string): number;
//# sourceMappingURL=key-search.d.cts.map