Spaces:
Sleeping
Sleeping
Download lib/client-utils.ts from KazukiWatanabe/FE_Dev: direct link, hf CLI and curl.
- Browser
- Download file 583 Bytes
-
https://huggingface.co/spaces/KazukiWatanabe/FE_Dev/resolve/main/lib/client-utils.ts
- Command line
-
hf download hf://spaces/KazukiWatanabe/FE_Dev/lib/client-utils.ts
-
curl -L -o client-utils.ts https://huggingface.co/spaces/KazukiWatanabe/FE_Dev/resolve/main/lib/client-utils.ts
583 Bytes
| 'use client'; | |
| /** | |
| * Base64URLエンコードされた文字列をUint8Arrayに変換 | |
| * ブラウザ環境でのみ使用される | |
| */ | |
| export function urlBase64ToUint8Array(base64String: string): Uint8Array<ArrayBuffer> { | |
| const padding = '='.repeat((4 - (base64String.length % 4)) % 4); | |
| const base64 = (base64String + padding).replace(/-/g, '+').replace(/_/g, '/'); | |
| const rawData = window.atob(base64); | |
| const outputArray = new Uint8Array(rawData.length); | |
| for (let i = 0; i < rawData.length; ++i) { | |
| outputArray[i] = rawData.charCodeAt(i); | |
| } | |
| return outputArray; | |
| } |