MCPcopy Index your code
hub / github.com/simstudioai/sim / parseBoundedNumber

Function parseBoundedNumber

apps/sim/lib/workspace-events/subscriptions.ts:85–94  ·  view source on GitHub ↗
(
  value: unknown,
  fallback: number,
  bounds: { min: number; max: number; integer?: boolean }
)

Source from the content-addressed store, hash-verified

83} as const
84
85function parseBoundedNumber(
86 value: unknown,
87 fallback: number,
88 bounds: { min: number; max: number; integer?: boolean }
89): number {
90 const parsed = typeof value === 'number' ? value : Number(value)
91 if (!Number.isFinite(parsed) || parsed <= 0) return fallback
92 const clamped = Math.min(Math.max(parsed, bounds.min), bounds.max)
93 return bounds.integer ? Math.round(clamped) : clamped
94}
95
96/**
97 * Parses a webhook row's providerConfig into a typed subscription config.

Callers 1

parseSubscriptionConfigFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected