mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-04-03 22:44:35 -04:00
* 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
17 lines
545 B
TypeScript
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
|
|
}
|