mirror of
https://github.com/Sevichecc/Urara-Blog.git
synced 2025-05-09 02:29:13 +08:00
1 line
No EOL
975 B
Text
1 line
No EOL
975 B
Text
import{Encoder as t}from"worktop/buffer";var n=()=>crypto.randomUUID();function r(t){for(var n="",r=t||11,e=a(r);r--;)n+="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-_"[63&e[r]];return n}var e="0123456789ABCDEFGHJKMNPQRSTVWXYZ";function o(){for(var t,n="",r=16,o=Date.now(),f=e.length,i=a(r);r--;)(t=i[r]/255*f|0)===f&&(t=31),n=e.charAt(t)+n;for(r=10;r--;)o=(o-(t=o%f))/f,n=e.charAt(t)+n;return n}function a(t){return crypto.getRandomValues(new Uint8Array(t))}function f(n){return n?t.encode(n).byteLength:0}async function i(t){let n=t.headers.get("content-type");if(t.body&&n)return~n.indexOf("application/json")?t.json():~n.indexOf("multipart/form-data")||~n.indexOf("application/x-www-form-urlencoded")?t.formData().then(u):~n.indexOf("text/")?t.text():t.arrayBuffer()}function u(t){let n,r,e,o={};for([n,r]of t)o[n]=void 0===(e=o[n])?r:[].concat(e,r);return o}export{i as body,f as byteLength,a as randomize,u as toObject,r as uid,o as ulid,n as uuid}; |