MCPcopy Index your code
hub / github.com/callstack/agent-device / normalizeScrollDurationMs

Function normalizeScrollDurationMs

src/core/scroll-command.ts:25–40  ·  view source on GitHub ↗
(
  durationMs: number | undefined,
  options: { field?: string; invalidMessage?: string; max?: number } = {},
)

Source from the content-addressed store, hash-verified

23}
24
25export function normalizeScrollDurationMs(
26 durationMs: number | undefined,
27 options: { field?: string; invalidMessage?: string; max?: number } = {},
28): number | undefined {
29 if (durationMs === undefined) return undefined;
30 const field = options.field ?? 'scroll durationMs';
31 const max = options.max ?? SCROLL_DURATION_MAX_MS;
32 const invalidMessage = options.invalidMessage ?? `${field} must be a non-negative integer`;
33 if (!Number.isFinite(durationMs) || !Number.isInteger(durationMs) || durationMs < 0) {
34 throw new AppError('INVALID_ARGS', invalidMessage);
35 }
36 if (durationMs > max) {
37 throw new AppError('INVALID_ARGS', `${field} must be a non-negative integer at most ${max}`);
38 }
39 return durationMs;
40}
41
42export function honoredScrollDurationMs(
43 result: Record<string, unknown> | undefined,

Callers 3

scrollCommandFunction · 0.90
runAppleScrollFunction · 0.90

Calls 1

isFiniteMethod · 0.80

Tested by

no test coverage detected