MCPcopy Index your code
hub / github.com/Effect-TS/effect / processSpace

Function processSpace

packages/cli/src/internal/prompt/multi-select.ts:207–237  ·  view source on GitHub ↗
(
  state: State,
  options: SelectOptions<A>
)

Source from the content-addressed store, hash-verified

205}
206
207function processSpace<A>(
208 state: State,
209 options: SelectOptions<A>
210) {
211 const selectedIndices = new Set(state.selectedIndices)
212 if (state.index === 0) {
213 if (state.selectedIndices.size === options.choices.length) {
214 selectedIndices.clear()
215 } else {
216 for (let i = 0; i < options.choices.length; i++) {
217 selectedIndices.add(i)
218 }
219 }
220 } else if (state.index === 1) {
221 for (let i = 0; i < options.choices.length; i++) {
222 if (state.selectedIndices.has(i)) {
223 selectedIndices.delete(i)
224 } else {
225 selectedIndices.add(i)
226 }
227 }
228 } else {
229 const choiceIndex = state.index - metaOptionsCount
230 if (selectedIndices.has(choiceIndex)) {
231 selectedIndices.delete(choiceIndex)
232 } else {
233 selectedIndices.add(choiceIndex)
234 }
235 }
236 return Effect.succeed(Action.NextFrame({ state: { ...state, selectedIndices } }))
237}
238
239export function handleClear<A>(options: SelectOptions<A>) {
240 return Effect.gen(function*() {

Callers 1

handleProcessFunction · 0.85

Calls 2

clearMethod · 0.80
addMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…