MCPcopy Create free account
hub / github.com/vercel/examples / toUnit

Function toUnit

websockets/nuxt/server/api/ws.ts:11–15  ·  view source on GitHub ↗

Clamp an untrusted coordinate into the normalized 0..1 range, or reject it.

(value: unknown)

Source from the content-addressed store, hash-verified

9
10/** Clamp an untrusted coordinate into the normalized 0..1 range, or reject it. */
11function toUnit(value: unknown): number | null {
12 return typeof value === 'number' && Number.isFinite(value)
13 ? Math.min(Math.max(value, 0), 1)
14 : null
15}
16
17function send(peer: { send: (data: string) => void }, msg: ServerMessage) {
18 peer.send(JSON.stringify(msg))

Callers 1

messageFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected