MCPcopy Create free account
hub / github.com/dailydotdev/apps / snapToHalf

Function snapToHalf

packages/shared/src/lib/utils.ts:55–66  ·  view source on GitHub ↗
(v: number)

Source from the content-addressed store, hash-verified

53};
54
55export const snapToHalf = (v: number): 0.0 | 0.5 | 1.0 => {
56 const x = Math.min(1, Math.max(0, v));
57
58 if (x < 0.25) {
59 return 0.0;
60 }
61 if (x < 0.75) {
62 return 0.5;
63 }
64
65 return 1.0;
66};
67
68export const locationToString = (loc: Partial<TLocation>) => {
69 if (!loc) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected