@flemist/simple-utils 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/browser/index.cjs +1 -1
- package/build/browser/index.mjs +1 -1
- package/build/common/index.cjs +1 -1
- package/build/common/index.mjs +1 -1
- package/build/node/index.cjs +1 -1
- package/build/node/index.mjs +1 -1
- package/build/{urlGet-CZFNBQ4G.js → urlGet-CtceHOCG.js} +3 -3
- package/build/{urlGet-B8-MSnoY.mjs → urlGet-DAHy2Rar.mjs} +51 -49
- package/package.json +5 -5
package/build/browser/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../urlGet-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../urlGet-CtceHOCG.js");exports.ConsoleMessageLevel=e.ConsoleMessageLevel;exports.Lazy=e.Lazy;exports.LazyWithId=e.LazyWithId;exports.Random=e.Random;exports.UNIQUE_PSEUDO_RANDOM_MAX_COUNT=e.UNIQUE_PSEUDO_RANDOM_MAX_COUNT;exports.alertReplace=e.alertReplace;exports.consoleReplace=e.consoleReplace;exports.convertTimeZone=e.convertTimeZone;exports.createUniquePseudoRandom=e.createUniquePseudoRandom;exports.dateNowUnique=e.dateNowUnique;exports.deepCloneJsonLike=e.deepCloneJsonLike;exports.deepEqualJsonLike=e.deepEqualJsonLike;exports.deepEqualJsonLikeMap=e.deepEqualJsonLikeMap;exports.equalArray=e.equalArray;exports.escapeHtml=e.escapeHtml;exports.escapeRegExp=e.escapeRegExp;exports.fixStackTrace=e.fixStackTrace;exports.formatAny=e.formatAny;exports.formatDate=e.formatDate;exports.formatDateFileName=e.formatDateFileName;exports.getDateInet=e.getDateInet;exports.getNormalizedObject=e.getNormalizedObject;exports.getRandomFunc=e.getRandomFunc;exports.getRandomSeed=e.getRandomSeed;exports.getStackTrace=e.getStackTrace;exports.max=e.max;exports.min=e.min;exports.minMax=e.minMax;exports.numberMod=e.numberMod;exports.randomBoolean=e.randomBoolean;exports.randomEnum=e.randomEnum;exports.randomFloat=e.randomFloat;exports.randomIndexWeighted=e.randomIndexWeighted;exports.randomInt=e.randomInt;exports.randomItem=e.randomItem;exports.randomItems=e.randomItems;exports.sha256=e.sha256;exports.sha256Buffer=e.sha256Buffer;exports.timeoutAbortController=e.timeoutAbortController;exports.toHex=e.toHex;exports.urlGetBoolean=e.urlGetBoolean;exports.urlGetFloat=e.urlGetFloat;exports.urlGetInt=e.urlGetInt;exports.urlGetParams=e.urlGetParams;exports.urlGetString=e.urlGetString;exports.urlParamToBoolean=e.urlParamToBoolean;exports.urlParamToFloat=e.urlParamToFloat;exports.urlParamToInt=e.urlParamToInt;exports.withConsoleReplace=e.withConsoleReplace;exports.withTimeout=e.withTimeout;
|
package/build/browser/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as s, M as o, N as t, R as n, U as r, E as m, G as l, q as d, l as u, o as i, z as c, A as p, B as g, C as I, x as R, y as T, I as f, u as x, v as h, w as E, p as L, D as M, d as N, g as P, J as U, b as k, m as q, c as A, n as C, f as D, k as F, r as G, h as S, e as y, i as B, j as O, a as b, s as w, K as z, t as J, V as _, X as v, W as H, O as W, T as j, P as Q, S as X, Q as K, H as V, L as Z } from "../urlGet-
|
|
1
|
+
import { F as s, M as o, N as t, R as n, U as r, E as m, G as l, q as d, l as u, o as i, z as c, A as p, B as g, C as I, x as R, y as T, I as f, u as x, v as h, w as E, p as L, D as M, d as N, g as P, J as U, b as k, m as q, c as A, n as C, f as D, k as F, r as G, h as S, e as y, i as B, j as O, a as b, s as w, K as z, t as J, V as _, X as v, W as H, O as W, T as j, P as Q, S as X, Q as K, H as V, L as Z } from "../urlGet-DAHy2Rar.mjs";
|
|
2
2
|
export {
|
|
3
3
|
s as ConsoleMessageLevel,
|
|
4
4
|
o as Lazy,
|
package/build/common/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../urlGet-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../urlGet-CtceHOCG.js");exports.ConsoleMessageLevel=e.ConsoleMessageLevel;exports.Lazy=e.Lazy;exports.LazyWithId=e.LazyWithId;exports.Random=e.Random;exports.UNIQUE_PSEUDO_RANDOM_MAX_COUNT=e.UNIQUE_PSEUDO_RANDOM_MAX_COUNT;exports.alertReplace=e.alertReplace;exports.consoleReplace=e.consoleReplace;exports.convertTimeZone=e.convertTimeZone;exports.createUniquePseudoRandom=e.createUniquePseudoRandom;exports.dateNowUnique=e.dateNowUnique;exports.deepCloneJsonLike=e.deepCloneJsonLike;exports.deepEqualJsonLike=e.deepEqualJsonLike;exports.deepEqualJsonLikeMap=e.deepEqualJsonLikeMap;exports.equalArray=e.equalArray;exports.escapeHtml=e.escapeHtml;exports.escapeRegExp=e.escapeRegExp;exports.fixStackTrace=e.fixStackTrace;exports.formatAny=e.formatAny;exports.formatDate=e.formatDate;exports.formatDateFileName=e.formatDateFileName;exports.getDateInet=e.getDateInet;exports.getNormalizedObject=e.getNormalizedObject;exports.getRandomFunc=e.getRandomFunc;exports.getRandomSeed=e.getRandomSeed;exports.getStackTrace=e.getStackTrace;exports.max=e.max;exports.min=e.min;exports.minMax=e.minMax;exports.numberMod=e.numberMod;exports.randomBoolean=e.randomBoolean;exports.randomEnum=e.randomEnum;exports.randomFloat=e.randomFloat;exports.randomIndexWeighted=e.randomIndexWeighted;exports.randomInt=e.randomInt;exports.randomItem=e.randomItem;exports.randomItems=e.randomItems;exports.sha256=e.sha256;exports.sha256Buffer=e.sha256Buffer;exports.timeoutAbortController=e.timeoutAbortController;exports.toHex=e.toHex;exports.urlGetBoolean=e.urlGetBoolean;exports.urlGetFloat=e.urlGetFloat;exports.urlGetInt=e.urlGetInt;exports.urlGetParams=e.urlGetParams;exports.urlGetString=e.urlGetString;exports.urlParamToBoolean=e.urlParamToBoolean;exports.urlParamToFloat=e.urlParamToFloat;exports.urlParamToInt=e.urlParamToInt;exports.withConsoleReplace=e.withConsoleReplace;exports.withTimeout=e.withTimeout;
|
package/build/common/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as s, M as o, N as t, R as n, U as r, E as m, G as l, q as d, l as u, o as i, z as c, A as p, B as g, C as I, x as R, y as T, I as f, u as x, v as h, w as E, p as L, D as M, d as N, g as P, J as U, b as k, m as q, c as A, n as C, f as D, k as F, r as G, h as S, e as y, i as B, j as O, a as b, s as w, K as z, t as J, V as _, X as v, W as H, O as W, T as j, P as Q, S as X, Q as K, H as V, L as Z } from "../urlGet-
|
|
1
|
+
import { F as s, M as o, N as t, R as n, U as r, E as m, G as l, q as d, l as u, o as i, z as c, A as p, B as g, C as I, x as R, y as T, I as f, u as x, v as h, w as E, p as L, D as M, d as N, g as P, J as U, b as k, m as q, c as A, n as C, f as D, k as F, r as G, h as S, e as y, i as B, j as O, a as b, s as w, K as z, t as J, V as _, X as v, W as H, O as W, T as j, P as Q, S as X, Q as K, H as V, L as Z } from "../urlGet-DAHy2Rar.mjs";
|
|
2
2
|
export {
|
|
3
3
|
s as ConsoleMessageLevel,
|
|
4
4
|
o as Lazy,
|
package/build/node/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../urlGet-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../urlGet-CtceHOCG.js"),N=require("@flemist/async-utils"),S=require("@flemist/time-limits"),b=require("node:os"),V=require("path"),W=require("@flemist/priority-queue"),ee=require("fs"),te=require("picomatch");function j(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const a in e)if(a!=="default"){const i=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(n,a,i.get?i:{enumerable:!0,get:()=>e[a]})}}return n.default=e,Object.freeze(n)}const w=j(V),z=j(ee),g=new S.Pool(b.cpus().length);function x(e){return e.replace(/\\/g,"/")}let I=null;function ne(e){I==null&&(I=new Map);const n=x(e);let a=I.get(n);return a==null&&(a=new N.Locker,I.set(n,a)),a}function re(e){const{filePath:n,func:a}=e;return ne(n).lock(()=>S.poolRunWait({pool:g,count:1,func:a}))}function B(e){return e.match(/^[/\\]?[^/\\]+/)[0]}function H(e,n){return B(e)+"|"+n.ino}function $(e){return e.endsWith(":")&&(e+="/"),w.resolve(e)}function _(e,n){e.totalSize+=n.totalSize,e.maxFileDateModified=Math.max(e.maxFileDateModified,n.maxFileDateModified),e.countFiles+=n.countFiles,e.countDirs+=n.countDirs,e.countLinks+=n.countLinks}const J=function(n){return n.code==="ENOENT"};function Q(e){const n=e.paths;if(!n||n.length===0)return Promise.resolve({totalSize:0,maxFileDateModified:0,countFiles:0,countDirs:0,countLinks:0});const a=e.level??0,i=e.walkedIds??new Set,r=e.abortSignal,u=e.pool??g,p=e.handleError,d=e.priority??W.priorityCreate(0),c=e.walkLinks??!1,m=e.log,F=e.handlePath,C=e.matchPath;async function R(L){if(!(p&&await p(L))&&!J(L))throw L}function Y(L){return!(!m||m.minTotalContentSize!=null&&L<m.minTotalContentSize||m.maxNestedLevel!=null&&a>m.maxNestedLevel)}return N.useAbortController(async L=>{const E=N.combineAbortSignals(r,L),T={totalSize:0,maxFileDateModified:0,countFiles:0,countDirs:0,countLinks:0};function q(f,y){if(Y(y.totalSize)){const s=`${y.totalSize.toLocaleString("en-US").replace(/,/g," ").padStart(19)}: ${f}`;m?.handleLog?m.handleLog(s):console.log(s)}}async function G(f,y,k,s){return F?await S.poolRunWait({pool:u,func:async()=>{try{return await F({level:a,path:f,stat:y,itemStat:k,totalStat:T,abortSignal:E})}catch(l){return await R(l),!1}},count:1,priority:s,abortSignal:E}):!0}async function O(f,y,k,s){s||(s=f);const l=await S.poolRunWait({pool:u,func:()=>z.promises.lstat(f).catch(R),count:1,priority:W.priorityCreate(y,W.priorityCreate(1,d)),abortSignal:E});if(!l||!k&&l.isFile())return null;const U=H(f,l);if(i.has(U))return null;i.add(U);let o={totalSize:l.size,maxFileDateModified:l.isDirectory()?0:l.mtimeMs,countFiles:0,countDirs:0,countLinks:0};const M=W.priorityCreate(y,W.priorityCreate(l.isDirectory()?2:3,d));if(l.isSymbolicLink()){if(c){const h=await S.poolRunWait({pool:u,func:()=>z.promises.readlink(f).catch(R).then(D=>D??null),count:1,priority:M,abortSignal:E});if(h){const D=w.isAbsolute(h)?h:w.resolve(w.dirname(s),h),v=await O(D,y,k,s);v&&(o=v)}}return(k||o.countFiles+o.countDirs+o.countLinks>=1)&&(o.countLinks+=1,await G(s,l,o,M)&&(_(T,o),q(s,o))),o}else if(l.isDirectory()){const h=await S.poolRunWait({pool:u,func:()=>z.promises.readdir(f).catch(R),count:1,priority:d,abortSignal:E});if(h){for(let D=0,v=h.length;D<v;D++)h[D]=w.join(s,h[D]);o=await Q({...e,paths:h,abortSignal:E,priority:M,level:a+1,walkedIds:i})}}return(k||o.countFiles+o.countDirs+o.countLinks>=1)&&(l.isDirectory()?o.countDirs+=1:l.isFile()&&(o.countFiles+=1),await G(s,l,o,M)&&(_(T,o),q(s,o))),o}const A=[];for(let f=0,y=n.length;f<y;f++){const k=$(n[f]),s=C?C(k):!0;s!==!1&&A.push(O(k,f,s))}return await Promise.all(A),T})}function ae(e){return Q(e)}function ie({globs:e,rootDir:n,noCase:a}){const i=[];return e.forEach(r=>{r=x(r).trim();const u=r.startsWith("^");u&&(r=r.substring(1).trim());const p=r.startsWith("!");if(p&&(r=r.substring(1).trim()),r.startsWith("!")||r.startsWith("^"))throw new Error(`Invalid glob pattern: "${r}". The syntax '${r.substring(0,2)}' is not supported. Valid glob patterns use: * (match any characters), ** (match any directories), ? (match single character), [abc] (character class), ! (negate pattern), ^ (exclude if included). Examples of valid patterns: "*.js", "src/**/*.ts", "!node_modules", "^dist". Avoid starting with '!' after '^' or multiple special prefixes.`);r.startsWith("/")&&(r="."+r);const d=x(n?w.resolve(n,r):r);if(!d)return;let c;try{c=te(d,{nocase:a??!1,dot:!0,strictBrackets:!0})}catch(m){throw new Error(`Invalid glob pattern: "${r}". ${m instanceof Error?m.message:"Unknown error"}. Valid glob patterns use: * (match any characters), ** (match any directories), ? (match single character), [abc] (character class with balanced brackets), ! (negate pattern), ^ (exclude if included). Examples: "*.js", "src/**/*.ts", "!node_modules", "[abc]def.txt". Ensure all brackets [ ] are properly closed and balanced.`)}i.push({exclude:u,negative:p,debugInfo:d,match:c})}),function(u){u=x(u);let p=null,d=!1;for(let c=0,m=i.length;c<m;c++){const F=i[c];F.match(u)&&(F.exclude?d=!F.negative:(p=!F.negative,d=!1))}return d?!1:p}}function X(e){const n=e.startsWith("!");return n&&(e=e.substring(1)),e.startsWith("/")?e=e.substring(1):!e.startsWith("**")&&!e.startsWith("../")&&(e=`**/${e}`),n&&(e="!"+e),e}function Z(e,n){if(!n||n===".")return e;const a=e.startsWith("^");a&&(e=e.substring(1));const i=e.startsWith("!");return i&&(e=e.substring(1)),e.startsWith("/")?(n.endsWith("/")&&(n=n.substring(0,n.length-1)),e=n+e):(n.endsWith("/")||(n+="/"),e.startsWith("./")?e=n+e.substring(2):e.startsWith("../")?e=n+e:(n.startsWith("..")&&(n=""),e.startsWith("**")?e=n+e:e=n+"**/"+e)),e=x(w.normalize(e)),i&&(e="!"+e),a&&(e="^"+e),e}function P(e){return"^"+e}async function K(e){const a=(await z.promises.readFile(e,"utf-8")).split(`
|
|
2
2
|
`),i=[];return a.forEach(r=>{r=r.trim(),!(!r||r.startsWith("#"))&&i.push(r)}),i}async function oe(e){const n=e.rootDir??".",a=[];if(!e.globs?.length)return a;const i=[];return e.globs.forEach(r=>{r.value&&(r.valueType==="file-contains-patterns"?i.push(r):r.valueType==="pattern"&&a.push(r.exclude?P(r.value):r.value))}),i.length&&await Promise.all(i.map(async r=>{await S.poolRunWait({pool:g,count:1,func:async()=>{const u=w.resolve(n,r.value),p=await K(u),d=w.relative(n,w.dirname(u));p.forEach(c=>{c=X(c),c=Z(c,d),a.push(r.exclude?P(c):c)})}})})),a}exports.ConsoleMessageLevel=t.ConsoleMessageLevel;exports.Lazy=t.Lazy;exports.LazyWithId=t.LazyWithId;exports.Random=t.Random;exports.UNIQUE_PSEUDO_RANDOM_MAX_COUNT=t.UNIQUE_PSEUDO_RANDOM_MAX_COUNT;exports.alertReplace=t.alertReplace;exports.consoleReplace=t.consoleReplace;exports.convertTimeZone=t.convertTimeZone;exports.createUniquePseudoRandom=t.createUniquePseudoRandom;exports.dateNowUnique=t.dateNowUnique;exports.deepCloneJsonLike=t.deepCloneJsonLike;exports.deepEqualJsonLike=t.deepEqualJsonLike;exports.deepEqualJsonLikeMap=t.deepEqualJsonLikeMap;exports.equalArray=t.equalArray;exports.escapeHtml=t.escapeHtml;exports.escapeRegExp=t.escapeRegExp;exports.fixStackTrace=t.fixStackTrace;exports.formatAny=t.formatAny;exports.formatDate=t.formatDate;exports.formatDateFileName=t.formatDateFileName;exports.getDateInet=t.getDateInet;exports.getNormalizedObject=t.getNormalizedObject;exports.getRandomFunc=t.getRandomFunc;exports.getRandomSeed=t.getRandomSeed;exports.getStackTrace=t.getStackTrace;exports.max=t.max;exports.min=t.min;exports.minMax=t.minMax;exports.numberMod=t.numberMod;exports.randomBoolean=t.randomBoolean;exports.randomEnum=t.randomEnum;exports.randomFloat=t.randomFloat;exports.randomIndexWeighted=t.randomIndexWeighted;exports.randomInt=t.randomInt;exports.randomItem=t.randomItem;exports.randomItems=t.randomItems;exports.sha256=t.sha256;exports.sha256Buffer=t.sha256Buffer;exports.timeoutAbortController=t.timeoutAbortController;exports.toHex=t.toHex;exports.urlGetBoolean=t.urlGetBoolean;exports.urlGetFloat=t.urlGetFloat;exports.urlGetInt=t.urlGetInt;exports.urlGetParams=t.urlGetParams;exports.urlGetString=t.urlGetString;exports.urlParamToBoolean=t.urlParamToBoolean;exports.urlParamToFloat=t.urlParamToFloat;exports.urlParamToInt=t.urlParamToInt;exports.withConsoleReplace=t.withConsoleReplace;exports.withTimeout=t.withTimeout;exports.createMatchPath=ie;exports.fileLock=re;exports.getDrive=B;exports.getFileId=H;exports.globGitIgnoreToPicomatch=X;exports.globToRelative=Z;exports.loadGlobs=oe;exports.loadGlobsFromFile=K;exports.pathNormalize=x;exports.pathResolve=$;exports.poolFs=g;exports.walkPathHandleErrorDefault=J;exports.walkPaths=ae;
|
package/build/node/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as mt, M as ht, N as pt, R as kt, U as wt, E as yt, G as xt, q as Lt, l as Dt, o as Ft, z as St, A as Et, B as Wt, C as zt, x as vt, y as Mt, I as Tt, u as It, v as Rt, w as Ct, p as Nt, D as At, d as Gt, g as Ut, J as Ot, b as $t, m as qt, c as Bt, n as _t, f as jt, k as Ht, r as Jt, h as Pt, e as Qt, i as Xt, j as gt, a as Kt, s as Zt, K as Yt, t as Vt, V as bt, X as te, W as ee, O as ne, T as se, P as ae, S as re, Q as ie, H as oe, L as ce } from "../urlGet-
|
|
1
|
+
import { F as mt, M as ht, N as pt, R as kt, U as wt, E as yt, G as xt, q as Lt, l as Dt, o as Ft, z as St, A as Et, B as Wt, C as zt, x as vt, y as Mt, I as Tt, u as It, v as Rt, w as Ct, p as Nt, D as At, d as Gt, g as Ut, J as Ot, b as $t, m as qt, c as Bt, n as _t, f as jt, k as Ht, r as Jt, h as Pt, e as Qt, i as Xt, j as gt, a as Kt, s as Zt, K as Yt, t as Vt, V as bt, X as te, W as ee, O as ne, T as se, P as ae, S as re, Q as ie, H as oe, L as ce } from "../urlGet-DAHy2Rar.mjs";
|
|
2
2
|
import { Locker as j, useAbortController as H, combineAbortSignals as J } from "@flemist/async-utils";
|
|
3
3
|
import { Pool as P, poolRunWait as F } from "@flemist/time-limits";
|
|
4
4
|
import Q from "node:os";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const B=require("@flemist/abort-controller-fast"),Z=require("@flemist/async-utils"),$t=require("@flemist/time-controller");let D=null;function Ut(){if(!D){D=new Array(256);for(let t=0;t<256;t++)D[t]=t.toString(16).padStart(2,"0")}return D}function ot(t){const e=Ut(),r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);let n="";for(let o=0,i=r.length;o<i;o++)n+=e[r[o]];return n}let X=null,it=null,q=null,st=null;function Tt(){X||(X=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),it=new Uint32Array(64),st=new TextEncoder,q=new Uint8Array(65536))}function ut(t){if(t==null)return null;Tt();const e=X,r=it,n=st;let o=q,i;if(typeof t=="string"){const m=t.length*3;o.length<m+128&&(o=q=new Uint8Array(m+128));const f=n.encodeInto(t,o);i=o.subarray(0,f.written)}else if(t instanceof Uint8Array)i=t;else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);else throw new Error(`[sha256Buffer] Unsupported content type: ${typeof t}`);const c=i.length,a=c+72>>>6<<6;o.length<a&&(o=q=new Uint8Array(a)),i!==o&&o.set(i),o[c]=128;for(let m=c+1;m<a;m++)o[m]=0;const T=c*8,R=T/4294967296|0,A=T|0;o[a-8]=R>>>24,o[a-7]=R>>>16,o[a-6]=R>>>8,o[a-5]=R,o[a-4]=A>>>24,o[a-3]=A>>>16,o[a-2]=A>>>8,o[a-1]=A;let y=1779033703,s=-1150833019,u=1013904242,l=-1521486534,p=1359893119,d=-1694144372,w=528734635,O=1541459225;for(let m=0;m<a;m+=64){for(let h=0;h<16;h++){const g=m+(h<<2);r[h]=o[g]<<24|o[g+1]<<16|o[g+2]<<8|o[g+3]}for(let h=16;h<64;h++){const g=r[h-15],U=r[h-2],
|
|
1
|
+
"use strict";const B=require("@flemist/abort-controller-fast"),Z=require("@flemist/async-utils"),$t=require("@flemist/time-controller");let D=null;function Ut(){if(!D){D=new Array(256);for(let t=0;t<256;t++)D[t]=t.toString(16).padStart(2,"0")}return D}function ot(t){const e=Ut(),r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);let n="";for(let o=0,i=r.length;o<i;o++)n+=e[r[o]];return n}let X=null,it=null,q=null,st=null;function Tt(){X||(X=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),it=new Uint32Array(64),st=new TextEncoder,q=new Uint8Array(65536))}function ut(t){if(t==null)return null;Tt();const e=X,r=it,n=st;let o=q,i;if(typeof t=="string"){const m=t.length*3;o.length<m+128&&(o=q=new Uint8Array(m+128));const f=n.encodeInto(t,o);i=o.subarray(0,f.written)}else if(t instanceof Uint8Array)i=t;else if(ArrayBuffer.isView(t))i=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);else throw new Error(`[sha256Buffer] Unsupported content type: ${typeof t}`);const c=i.length,a=c+72>>>6<<6;o.length<a&&(o=q=new Uint8Array(a)),i!==o&&o.set(i),o[c]=128;for(let m=c+1;m<a;m++)o[m]=0;const T=c*8,R=T/4294967296|0,A=T|0;o[a-8]=R>>>24,o[a-7]=R>>>16,o[a-6]=R>>>8,o[a-5]=R,o[a-4]=A>>>24,o[a-3]=A>>>16,o[a-2]=A>>>8,o[a-1]=A;let y=1779033703,s=-1150833019,u=1013904242,l=-1521486534,p=1359893119,d=-1694144372,w=528734635,O=1541459225;for(let m=0;m<a;m+=64){for(let h=0;h<16;h++){const g=m+(h<<2);r[h]=o[g]<<24|o[g+1]<<16|o[g+2]<<8|o[g+3]}for(let h=16;h<64;h++){const g=r[h-15],U=r[h-2],J=(g>>>7|g<<25)^(g>>>18|g<<14)^g>>>3,L=(U>>>17|U<<15)^(U>>>19|U<<13)^U>>>10;r[h]=r[h-16]+J+r[h-7]+L|0}let f=y,S=s,N=u,H=l,_=p,P=d,x=w,W=O;for(let h=0;h<64;h+=4)for(let g=0;g<4;g++){const U=h+g,J=(_>>>6|_<<26)^(_>>>11|_<<21)^(_>>>25|_<<7),L=W+J+(x^_&(P^x))+e[U]+r[U]|0,Ot=((f>>>2|f<<30)^(f>>>13|f<<19)^(f>>>22|f<<10))+(f&S^N&(f^S))|0;W=x,x=P,P=_,_=H+L|0,H=N,N=S,S=f,f=L+Ot|0}y=y+f|0,s=s+S|0,u=u+N|0,l=l+H|0,p=p+_|0,d=d+P|0,w=w+x|0,O=O+W|0}const E=new Uint8Array(32),G=[y,s,u,l,p,d,w,O];for(let m=0;m<8;m++){const f=G[m],S=m<<2;E[S]=f>>>24,E[S+1]=f>>>16&255,E[S+2]=f>>>8&255,E[S+3]=f&255}return E}function At(t){const e=ut(t);return e?ot(e):null}function lt(t,e){return t==null?e:e==null?t:Math.min(t,e)}function at(t,e){return t==null?e:e==null?t:Math.max(t,e)}function Et(t,e,r){return at(lt(t,e),r)}function Ct(t,e){return(t%e+e)%e}function Rt(t){return function(){let r=t+=1831565813;return r=Math.imul(r^r>>>15,r|1),r^=r+Math.imul(r^r>>>7,r|61),(r^r>>>14)/4294967296+.5}}function It(){return Math.random()}function xt(){return Math.random()*2**32>>>0}function ct(t){return t!=null?Rt(t):It}class V{_seed;_rnd;constructor(e){this._seed=e,this._rnd=ct(e)}get seed(){return this._seed}nextSeed(){return this.next()*2**32>>>0}nextRandom(){return new V(this.nextSeed())}next(){return this._rnd()}clone(){return new V(this._seed)}}function v(t,e,r){if(r==null&&(r=e,e=0),r<=e)throw new Error(`[random][randomFloat] toExclusive (${r}) must be greater than from (${e})`);return t.next()*(r-e)+e}function ft(t,e,r){return Math.floor(v(t,e,r))}function kt(t,e){return t.next()<(e??.5)}function Mt(t,e,r){if(Array.isArray(e)){const i=e;e=i.length,r=c=>i[c]}if(!r)throw new Error("[random][randomIndexWeighted] getWeight is required");let n=0;for(let i=0;i<e;i++)n+=r(i);if(n===0)return-1;let o=v(t,n);for(let i=0;i<e;i++)if(o-=r(i),o<0)return i;return e-1}function K(t,e){if(e.length===0)throw new Error("[random][randomItem] items is empty");const r=ft(t,e.length);return e[r]}function Nt(t,e,r){if(e.length===0)throw new Error("[random][randomItems] items is empty");const n=[];for(let o=0;o<r;o++)n.push(K(t,e));return n}function Pt(t,e,r){let n=Object.values(e);return r&&(n=n.filter(r)),K(t,n)}const ht=1073741789,F=(ht>>2)-1;function Lt(t=F,e){if(t<=0)throw new Error(`[random][PseudoRandom] count(${t}) must be > 0`);if(t>F)throw new Error(`[random][PseudoRandom] count(${t}) must be <= ${F}`);if(e==null&&(e=Math.floor(Math.random()*t)),e>=t)throw new Error(`[random][PseudoRandom] startFrom(${e}) must be < count(${t})`);let r=e;return function(){return r=(r+ht)%t,r}}let k=null;function Dt(){const t=Date.now();return k==null||t>k?(k=t,t):(k++,k)}async function qt({url:t,timeout:e}={}){t||(t=typeof window<"u"?"/":"https://google.com");let r;try{const n=new B.AbortControllerFast;r=e?setTimeout(()=>{n.abort()},e):null;const o=await fetch(t,{method:"HEAD",signal:B.toAbortSignal(n.signal)}),i=o.headers.get("date");if(!i)throw new Error(`[Now][getDateInet] No date header in response: ${o.status} ${t}`);return new Date(i).getTime()}finally{r&&clearTimeout(r)}}function j(t,e,r){const n=e==null?t:new Date(t.toLocaleString("en-US",{timeZone:e})),o=r==null?t:new Date(t.toLocaleString("en-US",{timeZone:r}));return new Date(t.getTime()+o.getTime()-n.getTime())}function mt(t,e){t=j(t,"UTC",e);const r=t.getUTCFullYear().toString().padStart(4,"0"),n=(t.getUTCMonth()+1).toString().padStart(2,"0"),o=t.getUTCDate().toString().padStart(2,"0"),i=t.getUTCHours().toString().padStart(2,"0"),c=t.getUTCMinutes().toString().padStart(2,"0"),a=t.getUTCSeconds().toString().padStart(2,"0");return`${r}-${n}-${o} ${i}:${c}:${a}`}let Ft=0;const b=new WeakMap;function $(t){if(b.has(t))return b.get(t);const e=Ft++;return b.set(t,e),e}function Bt(t,e){try{return t[e]}catch(r){return"Error: "+(r?.message||String(r))}}function I(t,e={},r=[],n=new Set){const{pretty:o,filter:i,maxDepth:c,maxItems:a,showObjectId:T,showArrayIndex:R,customToString:A}=e;if(A){const s=A(t,u=>I(u,e,r,n));if(s!=null)return s}const y=r.length;if(typeof t=="string")return JSON.stringify(t);if(t==null||typeof t!="object")return String(t);if(typeof t.byteLength=="number")return`${t.constructor.name}#${$(t)}[${t.byteLength}]`;if(t instanceof RegExp)return String(t);if(t instanceof Error)return t.stack||t.message||String(t);if(t instanceof Date)return mt(t);if(Array.isArray(t)){if(n.has(t)||c!=null&&y>=c)return`#${$(t)}`;const s=o?" ".repeat(y):"";let u="";T&&(u+=`#${$(t)} `),u+="[";const l=a!=null?Math.min(t.length,a):t.length;l>0&&o&&(u+=`
|
|
2
2
|
`);for(let p=0;p<l;p++){const d=[...r,String(p)];if(i!=null&&!i(d,t[p]))continue;const w=t[p],O=I(w,e,d);p>0&&(u+=",",o&&(u+=`
|
|
3
3
|
`)),o&&(u+=`${s} `),R&&(u+=`${p}: `),u+=`${O}`}return l>0&&o&&(u+=`
|
|
4
4
|
`),t.length>l&&(l>0&&(u+=","),u+=o?`${s} ...
|
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
`),d>=p){d>0&&(l+=","),l+=o?`${u} ...
|
|
7
7
|
`:"...";break}const O=[...r,w];if(i!=null&&!i(O,t[w]))continue;const E=Bt(t,w),G=I(E,e,O);d>0&&(l+=",",o&&(l+=`
|
|
8
8
|
`)),o&&(l+=`${u} `),l+=`${w}: ${G}`,d++}return d>0&&o&&(l+=`
|
|
9
|
-
${u}`),l+="}",l}}function Vt(t,e){t=j(t,"UTC",e);const r=t.getUTCFullYear().toString().padStart(4,"0"),n=(t.getUTCMonth()+1).toString().padStart(2,"0"),o=t.getUTCDate().toString().padStart(2,"0"),i=t.getUTCHours().toString().padStart(2,"0"),c=t.getUTCMinutes().toString().padStart(2,"0"),a=t.getUTCSeconds().toString().padStart(2,"0");return`${r}-${n}-${o}_${i}-${c}-${a}`}function zt(t){return t==null?null:t.replace(/[&<>"']/g,e=>{switch(e){case"&":return"&";case"<":return"<";case">":return"&rt;";case'"':return""";default:return"'"}})}function Gt(t){return t==null?null:t?.replace(/[/\\^$*+?.()|[\]{}]/g,"\\$&")}function Y(t){if(t==null)return null;if(Array.isArray(t)){const e=t.length,r=[];for(let n=0;n<e;n++)r.push(Y(t[n]));return r}if(typeof t=="object"){if(t.constructor&&t.constructor!==Object)throw new Error(`[deepCloneJsonLike] unexpected behavior: value.constructor (${t.constructor}) !== Object`);const e={};for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=Y(t[r]));return e}return t}function M(t,e){if(t===e)return!0;if(t==null)return e==null;if(e==null)return!1;if(Array.isArray(t)){if(!Array.isArray(e))return!1;const r=t.length;if(r!==e.length)return!1;for(let n=0;n<r;n++)if(!M(t[n],e[n]))return!1;return!0}if(typeof t=="object"){if(typeof e!="object")return!1;if(t.constructor&&t.constructor!==Object)throw new Error(`[deepEqual] unexpected behavior: a.constructor (${t.constructor}) !== Object`);if(e.constructor&&e.constructor!==Object)throw new Error(`[deepEqual] unexpected behavior: b.constructor (${e.constructor}) !== Object`);for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&!M(t[r],Object.prototype.hasOwnProperty.call(e,r)?e[r]:null))return!1;for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&!Object.prototype.hasOwnProperty.call(t,r)&&!M(e[r],null))return!1;return!0}return!1}function
|
|
9
|
+
${u}`),l+="}",l}}function Vt(t,e){t=j(t,"UTC",e);const r=t.getUTCFullYear().toString().padStart(4,"0"),n=(t.getUTCMonth()+1).toString().padStart(2,"0"),o=t.getUTCDate().toString().padStart(2,"0"),i=t.getUTCHours().toString().padStart(2,"0"),c=t.getUTCMinutes().toString().padStart(2,"0"),a=t.getUTCSeconds().toString().padStart(2,"0");return`${r}-${n}-${o}_${i}-${c}-${a}`}function zt(t){return t==null?null:t.replace(/[&<>"']/g,e=>{switch(e){case"&":return"&";case"<":return"<";case">":return"&rt;";case'"':return""";default:return"'"}})}function Gt(t){return t==null?null:t?.replace(/[/\\^$*+?.()|[\]{}]/g,"\\$&")}function Y(t){if(t==null)return null;if(Array.isArray(t)){const e=t.length,r=[];for(let n=0;n<e;n++)r.push(Y(t[n]));return r}if(typeof t=="object"){if(t.constructor&&t.constructor!==Object)throw new Error(`[deepCloneJsonLike] unexpected behavior: value.constructor (${t.constructor}) !== Object`);const e={};for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=Y(t[r]));return e}return t}function M(t,e){if(t===e)return!0;if(t==null)return e==null;if(e==null)return!1;if(Array.isArray(t)){if(!Array.isArray(e))return!1;const r=t.length;if(r!==e.length)return!1;for(let n=0;n<r;n++)if(!M(t[n],e[n]))return!1;return!0}if(typeof t=="object"){if(typeof e!="object")return!1;if(t.constructor&&t.constructor!==Object)throw new Error(`[deepEqual] unexpected behavior: a.constructor (${t.constructor}) !== Object`);if(e.constructor&&e.constructor!==Object)throw new Error(`[deepEqual] unexpected behavior: b.constructor (${e.constructor}) !== Object`);for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&!M(t[r],Object.prototype.hasOwnProperty.call(e,r)?e[r]:null))return!1;for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&!Object.prototype.hasOwnProperty.call(t,r)&&!M(e[r],null))return!1;return!0}return!1}function Ht(t,e){if(t==null||e==null)return t==null==(e==null);if(t.size!==e.size)return!1;for(const[r,n]of t)if(!M(n,e.get(r)))return!1;return!0}function Wt(t,e){const r=t.length;if(r!==e.length)return!1;for(let n=0;n<r;n++)if(t[n]!==e[n])return!1;return!0}function Q(t){return!t||typeof t!="object"?t:Array.isArray(t)?t.map(Q):t&&Object.keys(t).sort().reduce((e,r)=>{const n=Q(t[r]);return n!=null&&(e[r]=n),e},{})}function Jt(t){const e=alert;return window.alert=r=>t(e,r),()=>{window.alert=e}}var tt=(t=>(t.log="log",t.warn="warn",t.error="error",t.info="info",t.debug="debug",t.trace="trace",t.assert="assert",t))(tt||{});const et=Object.values(tt);function C(t){return function(){t.apply(console,arguments)}}const rt={log:C(console.log),warn:C(console.warn),error:C(console.error),info:C(console.info),debug:C(console.debug),trace:C(console.trace),assert:C(console.assert)};function pt(t){return et.forEach(e=>{console[e]=(...r)=>{t(rt,e,r)}}),()=>{et.forEach(e=>{console[e]=rt[e]})}}function bt(t){return function(r){const n=pt(t);try{const o=r();return Z.isPromiseLike(o)?o.then(i=>(n(),i),i=>{throw n(),i}):o}finally{n()}}}function dt(){let t=new Error().stack;if(t!=null){const e=t.indexOf(`
|
|
10
10
|
`);e!=null&&e>=0&&(t=t.substring(e+1))}return t??""}function Xt(t){return function(...e){const r=dt();try{return t.apply(this,e)}catch(n){throw n instanceof Error||(n=new Error(String(n))),n.stack=n.stack?n.stack+`
|
|
11
|
-
`+r:r,n}}}function gt(t){if(!t||t.timeout==null)return null;const e=new B.AbortControllerFast,r=t.timeController??$t.timeControllerDefault;if(t.timeout){const n=r.setTimeout(()=>{e.abort(new B.AbortError(`[timeoutAbortController] Timeout error: ${t.timeout}ms`))},t.timeout);e.signal.subscribe(()=>{clearTimeout(n)})}return t.abortSignal?.subscribe(n=>{e.abort(n)}),e}async function Yt(t,e){const r=gt(e);try{return await t(r?.signal??e?.abortSignal??null)}finally{r?.abort()}}class Qt{_options;_hasValue=!1;_promiseOrValue=null;constructor(e){this._options=e}run(){if(!this._hasValue){let e=this._options.func();const r=o=>(this._options.persist?this._promiseOrValue=o:(this._promiseOrValue=null,this._hasValue=!1),o),n=o=>{throw this._options.persist||(this._promiseOrValue=null,this._hasValue=!1),o};if(Z.isPromiseLike(e))e=e.then(r,n);else if(!this._options.persist)return e;this._promiseOrValue=e,this._hasValue=!0}return this._promiseOrValue}set(e){if(!this._options.persist)throw new Error("[Lazy][set] Cannot set value when persist is false");this._hasValue=!0,this._promiseOrValue=e}}class Zt{_options;_promiseOrValues=new Map;constructor(e){this._options=e}run(e){if(this._promiseOrValues.has(e))return this._promiseOrValues.get(e);let r=this._options.func(e);const n=i=>(this._options.persist?this._promiseOrValues.set(e,i):this._promiseOrValues.delete(e),i),o=i=>{throw this._options.persist||this._promiseOrValues.delete(e),i};if(Z.isPromiseLike(r))r=r.then(n,o);else if(!this._options.persist)return r;return this._promiseOrValues.set(e,r),r}set(e,r){if(!this._options.persist)throw new Error("[LazyWithId][set] Cannot set value when persist is false");this._promiseOrValues.set(e,r)}}function nt(t){return t.replace(/\W/g,"").toLowerCase()}function yt(t){return t instanceof URL?t.searchParams:t instanceof URLSearchParams?t:typeof t=="string"?new URL(t).searchParams:typeof window<"u"?new URL(window.location.href).searchParams:new URLSearchParams}function wt(t){return t==null?null:(t=t.toLowerCase().trim(),t==="true"||t==="1"||t==="yes"?!0:t==="false"||t==="0"||t==="no"?!1:null)}function St(t){if(t==null)return null;t=t.trim();const e=parseInt(t,10);return isNaN(e)?null:e}function _t(t){if(t==null)return null;t=t.trim();const e=parseFloat(t);return isNaN(e)?null:e}function z(t,e){const r=yt(e),n=nt(t);for(const[o,i]of r.entries())if(nt(o)===n)return i;return null}function vt(t,e){return wt(z(t,e))}function Kt(t,e){return St(z(t,e))}function jt(t,e){return _t(z(t,e))}exports.ConsoleMessageLevel=tt;exports.Lazy=Qt;exports.LazyWithId=Zt;exports.Random=V;exports.UNIQUE_PSEUDO_RANDOM_MAX_COUNT=F;exports.alertReplace=
|
|
11
|
+
`+r:r,n}}}function gt(t){if(!t||t.timeout==null)return null;const e=new B.AbortControllerFast,r=t.timeController??$t.timeControllerDefault;if(t.timeout){const n=r.setTimeout(()=>{e.abort(new B.AbortError(`[timeoutAbortController] Timeout error: ${t.timeout}ms`))},t.timeout);e.signal.subscribe(()=>{clearTimeout(n)})}return t.abortSignal?.subscribe(n=>{e.abort(n)}),e}async function Yt(t,e){const r=gt(e);try{return await t(r?.signal??e?.abortSignal??null)}finally{r?.abort()}}class Qt{_options;_hasValue=!1;_promiseOrValue=null;constructor(e){this._options=e}run(){if(!this._hasValue){let e=this._options.func();const r=o=>(this._options.persist?this._promiseOrValue=o:(this._promiseOrValue=null,this._hasValue=!1),o),n=o=>{throw this._options.persist||(this._promiseOrValue=null,this._hasValue=!1),o};if(Z.isPromiseLike(e))e=e.then(r,n);else if(!this._options.persist)return e;this._promiseOrValue=e,this._hasValue=!0}return this._promiseOrValue}set(e){if(!this._options.persist)throw new Error("[Lazy][set] Cannot set value when persist is false");this._hasValue=!0,this._promiseOrValue=e}}class Zt{_options;_promiseOrValues=new Map;constructor(e){this._options=e}run(e){if(this._promiseOrValues.has(e))return this._promiseOrValues.get(e);let r=this._options.func(e);const n=i=>(this._options.persist?this._promiseOrValues.set(e,i):this._promiseOrValues.delete(e),i),o=i=>{throw this._options.persist||this._promiseOrValues.delete(e),i};if(Z.isPromiseLike(r))r=r.then(n,o);else if(!this._options.persist)return r;return this._promiseOrValues.set(e,r),r}set(e,r){if(!this._options.persist)throw new Error("[LazyWithId][set] Cannot set value when persist is false");this._promiseOrValues.set(e,r)}}function nt(t){return t.replace(/\W/g,"").toLowerCase()}function yt(t){return t instanceof URL?t.searchParams:t instanceof URLSearchParams?t:typeof t=="string"?new URL(t).searchParams:typeof window<"u"?new URL(window.location.href).searchParams:new URLSearchParams}function wt(t){return t==null?null:(t=t.toLowerCase().trim(),t==="true"||t==="1"||t==="yes"?!0:t==="false"||t==="0"||t==="no"?!1:null)}function St(t){if(t==null)return null;t=t.trim();const e=parseInt(t,10);return isNaN(e)?null:e}function _t(t){if(t==null)return null;t=t.trim();const e=parseFloat(t);return isNaN(e)?null:e}function z(t,e){const r=yt(e),n=nt(t);for(const[o,i]of r.entries())if(nt(o)===n)return i;return null}function vt(t,e){return wt(z(t,e))}function Kt(t,e){return St(z(t,e))}function jt(t,e){return _t(z(t,e))}exports.ConsoleMessageLevel=tt;exports.Lazy=Qt;exports.LazyWithId=Zt;exports.Random=V;exports.UNIQUE_PSEUDO_RANDOM_MAX_COUNT=F;exports.alertReplace=Jt;exports.consoleReplace=pt;exports.convertTimeZone=j;exports.createUniquePseudoRandom=Lt;exports.dateNowUnique=Dt;exports.deepCloneJsonLike=Y;exports.deepEqualJsonLike=M;exports.deepEqualJsonLikeMap=Ht;exports.equalArray=Wt;exports.escapeHtml=zt;exports.escapeRegExp=Gt;exports.fixStackTrace=Xt;exports.formatAny=I;exports.formatDate=mt;exports.formatDateFileName=Vt;exports.getDateInet=qt;exports.getNormalizedObject=Q;exports.getRandomFunc=ct;exports.getRandomSeed=xt;exports.getStackTrace=dt;exports.max=at;exports.min=lt;exports.minMax=Et;exports.numberMod=Ct;exports.randomBoolean=kt;exports.randomEnum=Pt;exports.randomFloat=v;exports.randomIndexWeighted=Mt;exports.randomInt=ft;exports.randomItem=K;exports.randomItems=Nt;exports.sha256=At;exports.sha256Buffer=ut;exports.timeoutAbortController=gt;exports.toHex=ot;exports.urlGetBoolean=vt;exports.urlGetFloat=jt;exports.urlGetInt=Kt;exports.urlGetParams=yt;exports.urlGetString=z;exports.urlParamToBoolean=wt;exports.urlParamToFloat=_t;exports.urlParamToInt=St;exports.withConsoleReplace=bt;exports.withTimeout=Yt;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AbortControllerFast as j, toAbortSignal as lt, AbortError as at } from "@flemist/abort-controller-fast";
|
|
2
|
-
import { isPromiseLike as
|
|
2
|
+
import { isPromiseLike as X } from "@flemist/async-utils";
|
|
3
3
|
import { timeControllerDefault as ct } from "@flemist/time-controller";
|
|
4
4
|
let P = null;
|
|
5
5
|
function ft() {
|
|
@@ -113,8 +113,8 @@ function mt(t) {
|
|
|
113
113
|
o.length < a && (o = L = new Uint8Array(a)), s !== o && o.set(s), o[c] = 128;
|
|
114
114
|
for (let p = c + 1; p < a; p++)
|
|
115
115
|
o[p] = 0;
|
|
116
|
-
const A = c * 8, x = A / 4294967296 | 0,
|
|
117
|
-
o[a - 8] = x >>> 24, o[a - 7] = x >>> 16, o[a - 6] = x >>> 8, o[a - 5] = x, o[a - 4] =
|
|
116
|
+
const A = c * 8, x = A / 4294967296 | 0, E = A | 0;
|
|
117
|
+
o[a - 8] = x >>> 24, o[a - 7] = x >>> 16, o[a - 6] = x >>> 8, o[a - 5] = x, o[a - 4] = E >>> 24, o[a - 3] = E >>> 16, o[a - 2] = E >>> 8, o[a - 1] = E;
|
|
118
118
|
let y = 1779033703, i = -1150833019, u = 1013904242, l = -1521486534, m = 1359893119, d = -1694144372, g = 528734635, O = 1541459225;
|
|
119
119
|
for (let p = 0; p < a; p += 64) {
|
|
120
120
|
for (let h = 0; h < 16; h++) {
|
|
@@ -125,20 +125,20 @@ function mt(t) {
|
|
|
125
125
|
const w = r[h - 15], U = r[h - 2], F = (w >>> 7 | w << 25) ^ (w >>> 18 | w << 14) ^ w >>> 3, D = (U >>> 17 | U << 15) ^ (U >>> 19 | U << 13) ^ U >>> 10;
|
|
126
126
|
r[h] = r[h - 16] + F + r[h - 7] + D | 0;
|
|
127
127
|
}
|
|
128
|
-
let f = y, S = i,
|
|
128
|
+
let f = y, S = i, M = u, B = l, _ = m, N = d, R = g, z = O;
|
|
129
129
|
for (let h = 0; h < 64; h += 4)
|
|
130
130
|
for (let w = 0; w < 4; w++) {
|
|
131
|
-
const U = h + w, F = (_ >>> 6 | _ << 26) ^ (_ >>> 11 | _ << 21) ^ (_ >>> 25 | _ << 7), D = z + F + (R ^ _ & (N ^ R)) + e[U] + r[U] | 0, ut = ((f >>> 2 | f << 30) ^ (f >>> 13 | f << 19) ^ (f >>> 22 | f << 10)) + (f & S ^
|
|
132
|
-
z = R, R = N, N = _, _ = B + D | 0, B =
|
|
131
|
+
const U = h + w, F = (_ >>> 6 | _ << 26) ^ (_ >>> 11 | _ << 21) ^ (_ >>> 25 | _ << 7), D = z + F + (R ^ _ & (N ^ R)) + e[U] + r[U] | 0, ut = ((f >>> 2 | f << 30) ^ (f >>> 13 | f << 19) ^ (f >>> 22 | f << 10)) + (f & S ^ M & (f ^ S)) | 0;
|
|
132
|
+
z = R, R = N, N = _, _ = B + D | 0, B = M, M = S, S = f, f = D + ut | 0;
|
|
133
133
|
}
|
|
134
|
-
y = y + f | 0, i = i + S | 0, u = u +
|
|
134
|
+
y = y + f | 0, i = i + S | 0, u = u + M | 0, l = l + B | 0, m = m + _ | 0, d = d + N | 0, g = g + R | 0, O = O + z | 0;
|
|
135
135
|
}
|
|
136
|
-
const
|
|
136
|
+
const T = new Uint8Array(32), q = [y, i, u, l, m, d, g, O];
|
|
137
137
|
for (let p = 0; p < 8; p++) {
|
|
138
138
|
const f = q[p], S = p << 2;
|
|
139
|
-
|
|
139
|
+
T[S] = f >>> 24, T[S + 1] = f >>> 16 & 255, T[S + 2] = f >>> 8 & 255, T[S + 3] = f & 255;
|
|
140
140
|
}
|
|
141
|
-
return
|
|
141
|
+
return T;
|
|
142
142
|
}
|
|
143
143
|
function Pt(t) {
|
|
144
144
|
const e = mt(t);
|
|
@@ -171,7 +171,7 @@ function qt() {
|
|
|
171
171
|
function St(t) {
|
|
172
172
|
return t != null ? yt(t) : gt;
|
|
173
173
|
}
|
|
174
|
-
class
|
|
174
|
+
class J {
|
|
175
175
|
_seed;
|
|
176
176
|
_rnd;
|
|
177
177
|
constructor(e) {
|
|
@@ -184,13 +184,13 @@ class b {
|
|
|
184
184
|
return this.next() * 2 ** 32 >>> 0;
|
|
185
185
|
}
|
|
186
186
|
nextRandom() {
|
|
187
|
-
return new
|
|
187
|
+
return new J(this.nextSeed());
|
|
188
188
|
}
|
|
189
189
|
next() {
|
|
190
190
|
return this._rnd();
|
|
191
191
|
}
|
|
192
192
|
clone() {
|
|
193
|
-
return new
|
|
193
|
+
return new J(this._seed);
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
196
|
function rt(t, e, r) {
|
|
@@ -264,7 +264,7 @@ function Gt() {
|
|
|
264
264
|
const t = Date.now();
|
|
265
265
|
return I == null || t > I ? (I = t, t) : (I++, I);
|
|
266
266
|
}
|
|
267
|
-
async function
|
|
267
|
+
async function Jt({
|
|
268
268
|
url: t,
|
|
269
269
|
timeout: e
|
|
270
270
|
} = {}) {
|
|
@@ -322,7 +322,7 @@ function Ut(t, e) {
|
|
|
322
322
|
return "Error: " + (r?.message || String(r));
|
|
323
323
|
}
|
|
324
324
|
}
|
|
325
|
-
function
|
|
325
|
+
function k(t, e = {}, r = [], n = /* @__PURE__ */ new Set()) {
|
|
326
326
|
const {
|
|
327
327
|
pretty: o,
|
|
328
328
|
filter: s,
|
|
@@ -330,10 +330,10 @@ function M(t, e = {}, r = [], n = /* @__PURE__ */ new Set()) {
|
|
|
330
330
|
maxItems: a,
|
|
331
331
|
showObjectId: A,
|
|
332
332
|
showArrayIndex: x,
|
|
333
|
-
customToString:
|
|
333
|
+
customToString: E
|
|
334
334
|
} = e;
|
|
335
|
-
if (
|
|
336
|
-
const i =
|
|
335
|
+
if (E) {
|
|
336
|
+
const i = E(t, (u) => k(u, e, r, n));
|
|
337
337
|
if (i != null)
|
|
338
338
|
return i;
|
|
339
339
|
}
|
|
@@ -346,6 +346,8 @@ function M(t, e = {}, r = [], n = /* @__PURE__ */ new Set()) {
|
|
|
346
346
|
return `${t.constructor.name}#${$(t)}[${t.byteLength}]`;
|
|
347
347
|
if (t instanceof RegExp)
|
|
348
348
|
return String(t);
|
|
349
|
+
if (t instanceof Error)
|
|
350
|
+
return t.stack || t.message || String(t);
|
|
349
351
|
if (t instanceof Date)
|
|
350
352
|
return Ot(t);
|
|
351
353
|
if (Array.isArray(t)) {
|
|
@@ -361,7 +363,7 @@ function M(t, e = {}, r = [], n = /* @__PURE__ */ new Set()) {
|
|
|
361
363
|
const d = [...r, String(m)];
|
|
362
364
|
if (s != null && !s(d, t[m]))
|
|
363
365
|
continue;
|
|
364
|
-
const g = t[m], O =
|
|
366
|
+
const g = t[m], O = k(g, e, d);
|
|
365
367
|
m > 0 && (u += ",", o && (u += `
|
|
366
368
|
`)), o && (u += `${i} `), x && (u += `${m}: `), u += `${O}`;
|
|
367
369
|
}
|
|
@@ -373,13 +375,13 @@ function M(t, e = {}, r = [], n = /* @__PURE__ */ new Set()) {
|
|
|
373
375
|
if (n.has(t) || c != null && y >= c)
|
|
374
376
|
return `#${$(t)}`;
|
|
375
377
|
let i = "";
|
|
376
|
-
return A && (i += `#${$(t)} `), i += "Map", i +=
|
|
378
|
+
return A && (i += `#${$(t)} `), i += "Map", i += k(Array.from(t.entries()), e, r, n), i;
|
|
377
379
|
}
|
|
378
380
|
if (t instanceof Set) {
|
|
379
381
|
if (n.has(t) || c != null && y >= c)
|
|
380
382
|
return `#${$(t)}`;
|
|
381
383
|
let i = "";
|
|
382
|
-
return A && (i += `#${$(t)} `), i += "Set", i +=
|
|
384
|
+
return A && (i += `#${$(t)} `), i += "Set", i += k(Array.from(t.values()), e, r, n), i;
|
|
383
385
|
}
|
|
384
386
|
{
|
|
385
387
|
const i = t.prototype?.constructor === Object ? "" : t.prototype?.constructor.name;
|
|
@@ -400,7 +402,7 @@ function M(t, e = {}, r = [], n = /* @__PURE__ */ new Set()) {
|
|
|
400
402
|
const O = [...r, g];
|
|
401
403
|
if (s != null && !s(O, t[g]))
|
|
402
404
|
continue;
|
|
403
|
-
const
|
|
405
|
+
const T = Ut(t, g), q = k(T, e, O);
|
|
404
406
|
d > 0 && (l += ",", o && (l += `
|
|
405
407
|
`)), o && (l += `${u} `), l += `${g}: ${q}`, d++;
|
|
406
408
|
}
|
|
@@ -408,12 +410,12 @@ function M(t, e = {}, r = [], n = /* @__PURE__ */ new Set()) {
|
|
|
408
410
|
${u}`), l += "}", l;
|
|
409
411
|
}
|
|
410
412
|
}
|
|
411
|
-
function
|
|
413
|
+
function Xt(t, e) {
|
|
412
414
|
t = st(t, "UTC", e);
|
|
413
415
|
const r = t.getUTCFullYear().toString().padStart(4, "0"), n = (t.getUTCMonth() + 1).toString().padStart(2, "0"), o = t.getUTCDate().toString().padStart(2, "0"), s = t.getUTCHours().toString().padStart(2, "0"), c = t.getUTCMinutes().toString().padStart(2, "0"), a = t.getUTCSeconds().toString().padStart(2, "0");
|
|
414
416
|
return `${r}-${n}-${o}_${s}-${c}-${a}`;
|
|
415
417
|
}
|
|
416
|
-
function
|
|
418
|
+
function Yt(t) {
|
|
417
419
|
return t == null ? null : t.replace(/[&<>"']/g, (e) => {
|
|
418
420
|
switch (e) {
|
|
419
421
|
case "&":
|
|
@@ -429,16 +431,16 @@ function Xt(t) {
|
|
|
429
431
|
}
|
|
430
432
|
});
|
|
431
433
|
}
|
|
432
|
-
function
|
|
434
|
+
function bt(t) {
|
|
433
435
|
return t == null ? null : t?.replace(/[/\\^$*+?.()|[\]{}]/g, "\\$&");
|
|
434
436
|
}
|
|
435
|
-
function
|
|
437
|
+
function b(t) {
|
|
436
438
|
if (t == null)
|
|
437
439
|
return null;
|
|
438
440
|
if (Array.isArray(t)) {
|
|
439
441
|
const e = t.length, r = [];
|
|
440
442
|
for (let n = 0; n < e; n++)
|
|
441
|
-
r.push(
|
|
443
|
+
r.push(b(t[n]));
|
|
442
444
|
return r;
|
|
443
445
|
}
|
|
444
446
|
if (typeof t == "object") {
|
|
@@ -448,7 +450,7 @@ function Y(t) {
|
|
|
448
450
|
);
|
|
449
451
|
const e = {};
|
|
450
452
|
for (const r in t)
|
|
451
|
-
Object.prototype.hasOwnProperty.call(t, r) && (e[r] =
|
|
453
|
+
Object.prototype.hasOwnProperty.call(t, r) && (e[r] = b(t[r]));
|
|
452
454
|
return e;
|
|
453
455
|
}
|
|
454
456
|
return t;
|
|
@@ -558,7 +560,7 @@ function vt(t) {
|
|
|
558
560
|
const n = At(t);
|
|
559
561
|
try {
|
|
560
562
|
const o = r();
|
|
561
|
-
return
|
|
563
|
+
return X(o) ? o.then(
|
|
562
564
|
(s) => (n(), s),
|
|
563
565
|
(s) => {
|
|
564
566
|
throw n(), s;
|
|
@@ -569,7 +571,7 @@ function vt(t) {
|
|
|
569
571
|
}
|
|
570
572
|
};
|
|
571
573
|
}
|
|
572
|
-
function
|
|
574
|
+
function Et() {
|
|
573
575
|
let t = new Error().stack;
|
|
574
576
|
if (t != null) {
|
|
575
577
|
const e = t.indexOf(`
|
|
@@ -580,7 +582,7 @@ function Tt() {
|
|
|
580
582
|
}
|
|
581
583
|
function jt(t) {
|
|
582
584
|
return function(...e) {
|
|
583
|
-
const r =
|
|
585
|
+
const r = Et();
|
|
584
586
|
try {
|
|
585
587
|
return t.apply(this, e);
|
|
586
588
|
} catch (n) {
|
|
@@ -589,7 +591,7 @@ function jt(t) {
|
|
|
589
591
|
}
|
|
590
592
|
};
|
|
591
593
|
}
|
|
592
|
-
function
|
|
594
|
+
function Tt(t) {
|
|
593
595
|
if (!t || t.timeout == null)
|
|
594
596
|
return null;
|
|
595
597
|
const e = new j(), r = t.timeController ?? ct;
|
|
@@ -610,7 +612,7 @@ function Et(t) {
|
|
|
610
612
|
}), e;
|
|
611
613
|
}
|
|
612
614
|
async function te(t, e) {
|
|
613
|
-
const r =
|
|
615
|
+
const r = Tt(e);
|
|
614
616
|
try {
|
|
615
617
|
return await t(r?.signal ?? e?.abortSignal ?? null);
|
|
616
618
|
} finally {
|
|
@@ -630,7 +632,7 @@ class ee {
|
|
|
630
632
|
const r = (o) => (this._options.persist ? this._promiseOrValue = o : (this._promiseOrValue = null, this._hasValue = !1), o), n = (o) => {
|
|
631
633
|
throw this._options.persist || (this._promiseOrValue = null, this._hasValue = !1), o;
|
|
632
634
|
};
|
|
633
|
-
if (
|
|
635
|
+
if (X(e))
|
|
634
636
|
e = e.then(r, n);
|
|
635
637
|
else if (!this._options.persist)
|
|
636
638
|
return e;
|
|
@@ -657,7 +659,7 @@ class re {
|
|
|
657
659
|
const n = (s) => (this._options.persist ? this._promiseOrValues.set(e, s) : this._promiseOrValues.delete(e), s), o = (s) => {
|
|
658
660
|
throw this._options.persist || this._promiseOrValues.delete(e), s;
|
|
659
661
|
};
|
|
660
|
-
if (
|
|
662
|
+
if (X(r))
|
|
661
663
|
r = r.then(n, o);
|
|
662
664
|
else if (!this._options.persist)
|
|
663
665
|
return r;
|
|
@@ -694,7 +696,7 @@ function It(t) {
|
|
|
694
696
|
const e = parseFloat(t);
|
|
695
697
|
return isNaN(e) ? null : e;
|
|
696
698
|
}
|
|
697
|
-
function
|
|
699
|
+
function Y(t, e) {
|
|
698
700
|
const r = Ct(e), n = v(t);
|
|
699
701
|
for (const [o, s] of r.entries())
|
|
700
702
|
if (v(o) === n)
|
|
@@ -702,13 +704,13 @@ function X(t, e) {
|
|
|
702
704
|
return null;
|
|
703
705
|
}
|
|
704
706
|
function ne(t, e) {
|
|
705
|
-
return xt(
|
|
707
|
+
return xt(Y(t, e));
|
|
706
708
|
}
|
|
707
709
|
function oe(t, e) {
|
|
708
|
-
return Rt(
|
|
710
|
+
return Rt(Y(t, e));
|
|
709
711
|
}
|
|
710
712
|
function se(t, e) {
|
|
711
|
-
return It(
|
|
713
|
+
return It(Y(t, e));
|
|
712
714
|
}
|
|
713
715
|
export {
|
|
714
716
|
V as A,
|
|
@@ -720,17 +722,17 @@ export {
|
|
|
720
722
|
At as G,
|
|
721
723
|
vt as H,
|
|
722
724
|
jt as I,
|
|
723
|
-
|
|
724
|
-
|
|
725
|
+
Et as J,
|
|
726
|
+
Tt as K,
|
|
725
727
|
te as L,
|
|
726
728
|
ee as M,
|
|
727
729
|
re as N,
|
|
728
730
|
Ct as O,
|
|
729
731
|
xt as P,
|
|
730
732
|
Rt as Q,
|
|
731
|
-
|
|
733
|
+
J as R,
|
|
732
734
|
It as S,
|
|
733
|
-
|
|
735
|
+
Y as T,
|
|
734
736
|
H as U,
|
|
735
737
|
ne as V,
|
|
736
738
|
oe as W,
|
|
@@ -750,15 +752,15 @@ export {
|
|
|
750
752
|
dt as m,
|
|
751
753
|
Vt as n,
|
|
752
754
|
Gt as o,
|
|
753
|
-
|
|
755
|
+
Jt as p,
|
|
754
756
|
st as q,
|
|
755
757
|
rt as r,
|
|
756
758
|
mt as s,
|
|
757
759
|
ht as t,
|
|
758
|
-
|
|
760
|
+
k as u,
|
|
759
761
|
Ot as v,
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
762
|
+
Xt as w,
|
|
763
|
+
Yt as x,
|
|
764
|
+
bt as y,
|
|
765
|
+
b as z
|
|
764
766
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flemist/simple-utils",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Simple simple utils",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"types": "build/common/index.d.ts",
|
|
@@ -119,10 +119,10 @@
|
|
|
119
119
|
"check:types": "tsc --noEmit",
|
|
120
120
|
"check": "run-p audit check:types lint",
|
|
121
121
|
"========================= test =========================": "",
|
|
122
|
-
"test:node": "vitest --run --project node --bail 3",
|
|
123
|
-
"test:browser": "vitest --run --project browser --bail 3",
|
|
124
|
-
"test:chrome": "vitest --run --project browser --browser chromium --bail 3",
|
|
125
|
-
"test:all": "vitest --run --bail 3",
|
|
122
|
+
"test:node": "vitest --run --config vitest.projects.ts --project node --bail 3",
|
|
123
|
+
"test:browser": "vitest --run --config vitest.projects.ts --project browser --bail 3",
|
|
124
|
+
"test:chrome": "vitest --run --config vitest.projects.ts --project browser --browser chromium --bail 3",
|
|
125
|
+
"test:all": "vitest --run --config vitest.projects.ts --bail 3",
|
|
126
126
|
"test": "run-s test:node test:browser",
|
|
127
127
|
"========================= dev =========================": "",
|
|
128
128
|
"kill-node": "taskkill /F /IM node.exe",
|