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

Function integer

packages/cli/src/internal/prompt/number.ts:275–297  ·  view source on GitHub ↗
(options: Prompt.Prompt.IntegerOptions)

Source from the content-addressed store, hash-verified

273
274/** @internal */
275export const integer = (options: Prompt.Prompt.IntegerOptions): Prompt.Prompt<number> => {
276 const opts: IntegerOptions = {
277 min: Number.NEGATIVE_INFINITY,
278 max: Number.POSITIVE_INFINITY,
279 incrementBy: 1,
280 decrementBy: 1,
281 validate: (n) => {
282 if (n < opts.min) {
283 return Effect.fail(`${n} must be greater than or equal to ${opts.min}`)
284 }
285 if (n > opts.max) {
286 return Effect.fail(`${n} must be less than or equal to ${opts.max}`)
287 }
288 return Effect.succeed(n)
289 },
290 ...options
291 }
292 return InternalPrompt.custom(initialState, {
293 render: handleRenderInteger(opts),
294 process: handleProcessInteger(opts),
295 clear: handleClear(opts)
296 })
297}
298
299function handleRenderFloat(options: FloatOptions) {
300 return (state: State, action: Prompt.Prompt.Action<State, number>) => {

Callers

nothing calls this directly

Calls 4

handleRenderIntegerFunction · 0.85
handleProcessIntegerFunction · 0.85
handleClearFunction · 0.70
failMethod · 0.65

Tested by

no test coverage detected