(options: Prompt.Prompt.IntegerOptions)
| 273 | |
| 274 | /** @internal */ |
| 275 | export 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 | |
| 299 | function handleRenderFloat(options: FloatOptions) { |
| 300 | return (state: State, action: Prompt.Prompt.Action<State, number>) => { |
nothing calls this directly
no test coverage detected