mirror of
https://github.com/Sevichecc/Urara-Blog.git
synced 2025-05-02 03:09:31 +08:00
1 line
No EOL
1,009 B
Text
1 line
No EOL
1,009 B
Text
const { Encoder:t } = require('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}exports.body=i;exports.byteLength=f;exports.randomize=a;exports.toObject=u;exports.uid=r;exports.ulid=o;exports.uuid=n; |