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

Function defaultIntProcessor

packages/effect/src/cli/Prompt.ts:3087–3102  ·  view source on GitHub ↗
(input: string, state: NumberState)

Source from the content-addressed store, hash-verified

3085const formatNumberInput = (value: number): string => Object.is(value, -0) ? "-0" : `${value}`
3086
3087const defaultIntProcessor = (input: string, state: NumberState) => {
3088 if (state.value.length === 0 && input === "-") {
3089 return Effect.succeed(Action.NextFrame({
3090 state: { ...state, value: "-", error: Option.none() }
3091 }))
3092 }
3093
3094 const parsed = globalThis.Number.parseInt(state.value + input)
3095 if (globalThis.Number.isNaN(parsed)) {
3096 return Effect.succeed(Action.Beep())
3097 } else {
3098 return Effect.succeed(Action.NextFrame({
3099 state: { ...state, value: formatNumberInput(parsed), error: Option.none() }
3100 }))
3101 }
3102}
3103
3104const defaultFloatProcessor = (input: string, state: NumberState) => {
3105 if (input === "." && state.value.includes(".")) {

Callers 1

handleProcessIntegerFunction · 0.85

Calls 2

formatNumberInputFunction · 0.85
succeedMethod · 0.45

Tested by

no test coverage detected