MCPcopy Create free account
hub / github.com/Effect-TS/effect / filterAutoCompleteChoices

Function filterAutoCompleteChoices

packages/effect/src/unstable/cli/Prompt.ts:3062–3071  ·  view source on GitHub ↗
(choices: ReadonlyArray<SelectChoice<A>>, query: string)

Source from the content-addressed store, hash-verified

3060interface AutoCompleteOptionsReq<A> extends Required<AutoCompleteOptions<A>> {}
3061
3062const filterAutoCompleteChoices = <A>(choices: ReadonlyArray<SelectChoice<A>>, query: string) => {
3063 const normalizedQuery = query.toLowerCase()
3064 const indices: Array<number> = []
3065 for (let i = 0; i < choices.length; i++) {
3066 if (choices[i].title.toLowerCase().includes(normalizedQuery)) {
3067 indices.push(i)
3068 }
3069 }
3070 return indices
3071}
3072
3073const updateAutoCompleteState = <A>(
3074 state: AutoCompleteState,

Callers 2

autoCompleteFunction · 0.85
updateAutoCompleteStateFunction · 0.85

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected