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

Function defaultFloatProcessor

packages/cli/src/internal/prompt/number.ts:172–195  ·  view source on GitHub ↗
(
  state: State,
  input: string
)

Source from the content-addressed store, hash-verified

170}
171
172function defaultFloatProcessor(
173 state: State,
174 input: string
175) {
176 if (input === "." && state.value.includes(".")) {
177 return Effect.succeed(Action.Beep())
178 }
179 if (state.value.length === 0 && input === "-") {
180 return Effect.succeed(Action.NextFrame({
181 state: { ...state, value: "-", error: Option.none() }
182 }))
183 }
184 return Effect.match(parseFloat(state.value + input), {
185 onFailure: () => Action.Beep(),
186 onSuccess: (value) =>
187 Action.NextFrame({
188 state: {
189 ...state,
190 value: input === "." ? `${value}.` : `${value}`,
191 error: Option.none()
192 }
193 })
194 })
195}
196
197const initialState: State = {
198 cursor: 0,

Callers 1

handleProcessFloatFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…