Resolve a numeric option with a fallback, throwing on defined-but-invalid values.
A defined value that is not a finite, positive integer (for example
perPage: -5, NaN, 0, or 2.7) is a caller bug and throws a
TypeError instead of silently coercing to the fallback. A negative
maxPages typo silently becoming a 100-page traversal is far harder to
debug than a thrown error at the call site. This matches the
fail-fast convention of resolveAgents and resolveRequestOptions.
Fractional values are floored (the only defensible coercion for a
count-like option); undefined falls back.
Parameters
value: number|undefined
The caller-supplied value (may be undefined).
fallback: number
The default to use when value is undefined.
name: string = "option"
The option name used in the error message.
Returns number
A positive, finite integer.
Throws
A TypeError when value is defined but not a finite, positive number.
Resolve a numeric option with a fallback, throwing on defined-but-invalid values.
A defined value that is not a finite, positive integer (for example
perPage: -5,NaN,0, or2.7) is a caller bug and throws aTypeErrorinstead of silently coercing to the fallback. A negativemaxPagestypo silently becoming a 100-page traversal is far harder to debug than a thrown error at the call site. This matches the fail-fast convention ofresolveAgentsandresolveRequestOptions. Fractional values are floored (the only defensible coercion for a count-like option);undefinedfalls back.