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

Function filterAutoCompleteChoices

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

Source from the content-addressed store, hash-verified

3290interface AutoCompleteOptionsReq<A> extends OptionsReq<AutoCompleteOptions<A>> {}
3291
3292const filterAutoCompleteChoices = <A>(choices: ReadonlyArray<SelectChoice<A>>, query: string) => {
3293 const normalizedQuery = query.toLowerCase()
3294 const indices: Array<number> = []
3295 for (let i = 0; i < choices.length; i++) {
3296 if (choices[i].title.toLowerCase().includes(normalizedQuery)) {
3297 indices.push(i)
3298 }
3299 }
3300 return indices
3301}
3302
3303const updateAutoCompleteState = <A>(
3304 state: AutoCompleteState,

Callers 2

AutoCompleteFunction · 0.85
updateAutoCompleteStateFunction · 0.85

Calls 1

pushMethod · 0.65

Tested by

no test coverage detected