Skip to content

@mega-yfue/eufy-sdk / clamp

Function: clamp()

ts
function clamp(
   value, 
   min, 
   max
): number;

Round to an integer and clamp into [min, max]. For scalar device params that take a bounded int (volume/brightness/color-temp 0..100, etc.), dispatched fire-and-forget — a non-numeric or out-of-range input must never reach the wire as-is. NaN input (e.g. Number("x")) fails safe to min: Math.max/Math.min propagate NaN rather than ignoring it, so that has to be checked explicitly, not relied on implicitly.

Parameters

value

number

min

number

max

number

Returns

number

Independent and unofficial. Not affiliated with, endorsed by, or sponsored by Anker Innovations, Anker eufy, or eufy. "Anker eufy", "eufy" and "Anker" are trademarks of their respective owners. Use responsibly — rapid or failed logins can trigger captcha or temporary cooldowns.