Files
Compass/common/src/edge/og.ts
Martin Braquet ba9b3cfb06 Add pretty formatting (#29)
* Test

* Add pretty formatting

* Fix Tests

* Fix Tests

* Fix Tests

* Fix

* Add pretty formatting fix

* Fix

* Test

* Fix tests

* Clean typeckech

* Add prettier check

* Fix api tsconfig

* Fix api tsconfig

* Fix tsconfig

* Fix

* Fix

* Prettier
2026-02-20 17:32:27 +01:00

17 lines
545 B
TypeScript

// see https://vercel.com/docs/concepts/functions/edge-functions/edge-functions-api for restrictions
export type Point = {x: number; y: number}
export function base64toPoints(base64urlString: string) {
const b64 = base64urlString.replace(/-/g, '+').replace(/_/g, '/')
const bin = atob(b64)
const u = Uint8Array.from(bin, (c) => c.charCodeAt(0))
const f = new Float32Array(u.buffer)
const points = [] as {x: number; y: number}[]
for (let i = 0; i < f.length; i += 2) {
points.push({x: f[i], y: f[i + 1]})
}
return points
}