MCPcopy
hub / github.com/anomalyco/opencode / search

Function search

packages/tui/src/context/sync.tsx:41–52  ·  view source on GitHub ↗
(items: T[], target: string, key: (item: T) => string)

Source from the content-addressed store, hash-verified

39}
40
41function search<T>(items: T[], target: string, key: (item: T) => string) {
42 let left = 0
43 let right = items.length - 1
44 while (left <= right) {
45 const middle = Math.floor((left + right) / 2)
46 const value = key(items[middle])
47 if (value === target) return { found: true, index: middle }
48 if (value < target) left = middle + 1
49 else right = middle - 1
50 }
51 return { found: false, index: left }
52}
53
54export const {
55 context: SyncContext,

Callers 6

sync.tsxFile · 0.70
getFunction · 0.70
syncFunction · 0.70
DialogSessionListFunction · 0.50
recoverFunction · 0.50
AutocompleteFunction · 0.50

Calls 1

keyFunction · 0.50

Tested by

no test coverage detected