@catstral/levy-utils 1.0.0 → 2.0.0
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/README.md +1370 -59
- package/dist/array/index.d.ts +20 -7
- package/dist/array/utils/cluster/index.d.ts +2 -3
- package/dist/array/utils/concat/index.d.ts +14 -0
- package/dist/array/utils/counting/index.d.ts +2 -2
- package/dist/array/utils/filter/index.d.ts +55 -0
- package/dist/array/utils/filterMap/index.d.ts +14 -0
- package/dist/array/utils/first/index.d.ts +13 -0
- package/dist/array/utils/group/index.d.ts +14 -0
- package/dist/array/utils/hasItems/index.d.ts +13 -0
- package/dist/array/utils/isArray/index.d.ts +9 -0
- package/dist/array/utils/last/index.d.ts +14 -0
- package/dist/array/utils/list/index.d.ts +2 -2
- package/dist/array/utils/map/index.d.ts +29 -0
- package/dist/array/utils/max/index.d.ts +24 -0
- package/dist/array/utils/min/index.d.ts +24 -0
- package/dist/array/utils/overflow/index.d.ts +20 -0
- package/dist/array/utils/reduce/index.d.ts +44 -0
- package/dist/array/utils/select/index.d.ts +126 -9
- package/dist/array/utils/sift/index.d.ts +1 -1
- package/dist/array/utils/sum/index.d.ts +13 -0
- package/dist/array/utils/toggle/index.d.ts +2 -2
- package/dist/callback/index.d.ts +8 -3
- package/dist/callback/utils/compose/index.d.ts +43 -0
- package/dist/callback/utils/noop/index.d.ts +8 -0
- package/dist/callback/utils/pipe/index.d.ts +12 -0
- package/dist/callback/utils/preset/index.d.ts +15 -0
- package/dist/callback/utils/retry/index.d.ts +2 -2
- package/dist/callback/utils/task/index.d.ts +12 -0
- package/dist/index.d.ts +9 -8
- package/dist/index.js +5 -0
- package/dist/misc/index.d.ts +17 -5
- package/dist/misc/utils/identity/index.d.ts +10 -0
- package/dist/misc/utils/isNull/index.d.ts +9 -0
- package/dist/misc/utils/isNullish/index.d.ts +13 -0
- package/dist/misc/utils/isPrimitive/index.d.ts +2 -2
- package/dist/misc/utils/isPromise/index.d.ts +9 -0
- package/dist/misc/utils/isPromiseLike/index.d.ts +9 -0
- package/dist/misc/utils/isUndefined/index.d.ts +9 -0
- package/dist/misc/utils/match/index.d.ts +22 -0
- package/dist/misc/utils/option/index.d.ts +54 -0
- package/dist/misc/utils/raise/index.d.ts +19 -0
- package/dist/misc/utils/range/index.d.ts +218 -11
- package/dist/misc/utils/readOnly/index.d.ts +47 -0
- package/dist/misc/utils/sleep/index.d.ts +2 -2
- package/dist/misc/utils/timeout/index.d.ts +40 -0
- package/dist/misc/utils/values/index.d.ts +13 -0
- package/dist/number/index.d.ts +13 -2
- package/dist/number/math/index.d.ts +2 -0
- package/dist/number/math/utils/isPrime/index.d.ts +9 -0
- package/dist/number/math/utils/mod/index.d.ts +10 -0
- package/dist/number/types.d.ts +11 -0
- package/dist/number/utils/clamp/index.d.ts +13 -0
- package/dist/number/utils/isDecimal/index.d.ts +11 -0
- package/dist/number/utils/isEven/index.d.ts +9 -0
- package/dist/number/utils/isInteger/index.d.ts +11 -0
- package/dist/number/utils/isOdd/index.d.ts +9 -0
- package/dist/number/utils/negative/index.d.ts +21 -0
- package/dist/number/utils/positive/index.d.ts +21 -0
- package/dist/number/utils/sign/index.d.ts +14 -0
- package/dist/number/utils/toInt/index.d.ts +1 -1
- package/dist/number/utils/trunc/index.d.ts +16 -0
- package/dist/object/index.d.ts +6 -5
- package/dist/object/utils/extend/index.d.ts +21 -0
- package/dist/random/helper.d.ts +6 -0
- package/dist/random/index.d.ts +6 -0
- package/dist/random/utils/chance/index.d.ts +13 -0
- package/dist/random/utils/draw/index.d.ts +13 -0
- package/dist/random/utils/maybe/index.d.ts +8 -0
- package/dist/random/utils/random/index.d.ts +14 -0
- package/dist/random/utils/scatter/index.d.ts +30 -0
- package/dist/random/utils/shuffle/index.d.ts +11 -0
- package/dist/random/utils/uid/index.d.ts +12 -0
- package/dist/random/uuid/helpers.d.ts +4 -0
- package/dist/random/uuid/index.d.ts +5 -0
- package/dist/random/uuid/types.d.ts +16 -0
- package/dist/random/uuid/utils/max/index.d.ts +8 -0
- package/dist/random/uuid/utils/nil/index.d.ts +8 -0
- package/dist/random/uuid/utils/v1/index.d.ts +46 -0
- package/dist/random/uuid/utils/v4/index.d.ts +22 -0
- package/dist/random/uuid/utils/v7/index.d.ts +34 -0
- package/dist/string/casing/index.d.ts +11 -11
- package/dist/string/casing/utils/camel/index.d.ts +1 -1
- package/dist/string/casing/utils/custom/index.d.ts +1 -1
- package/dist/string/casing/utils/http/index.d.ts +1 -1
- package/dist/string/casing/utils/kebab/index.d.ts +1 -1
- package/dist/string/casing/utils/pascal/index.d.ts +1 -1
- package/dist/string/casing/utils/snake/index.d.ts +1 -1
- package/dist/string/casing/utils/title/index.d.ts +1 -1
- package/dist/string/index.d.ts +4 -4
- package/dist/types.d.ts +2 -0
- package/package.json +8 -13
- package/dist/levyUtils.cjs +0 -5
- package/dist/levyUtils.js +0 -1198
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Promisable } from "~/types";
|
|
2
|
+
/**
|
|
3
|
+
* Executes the given callback in asynchronous context.
|
|
4
|
+
*
|
|
5
|
+
* If no callback is given, it yields execution to the microtask queue.
|
|
6
|
+
*
|
|
7
|
+
* The time complexity for this is `O(1)`.
|
|
8
|
+
*
|
|
9
|
+
* @param {() => Promisable<void>} [callback] An optional callback to execute
|
|
10
|
+
* @returns {Promise<void>} A Promise that resolves after the callback has completed or execution has yielded to the microtask queue
|
|
11
|
+
*/
|
|
12
|
+
export declare function task(callback?: () => Promisable<void>): Promise<void>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export
|
|
1
|
+
export * from "./array";
|
|
2
|
+
export * from "./callback";
|
|
3
|
+
export * from "./error";
|
|
4
|
+
export * from "./misc";
|
|
5
|
+
export * from "./number";
|
|
6
|
+
export * from "./object";
|
|
7
|
+
export * from "./random";
|
|
8
|
+
export * from "./string";
|
|
9
|
+
export type * from "./types";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
var fe=Object.create;var{getPrototypeOf:pe,defineProperty:q,getOwnPropertyNames:de}=Object;var z=Object.prototype.hasOwnProperty;function ge(e){return this[e]}var me,he,Te=(e,n,t)=>{var r=e!=null&&typeof e==="object";if(r){var s=n?me??=new WeakMap:he??=new WeakMap,i=s.get(e);if(i)return i}t=e!=null?fe(pe(e)):{};let o=n||!e||!e.__esModule||!z.call(e,"default")?q(t,"default",{value:e,enumerable:!0}):t;if(e&&typeof e==="object"||typeof e==="function"){for(let a of de(e))if(!z.call(o,a))q(o,a,{get:ge.bind(e,a),enumerable:!0})}if(r)s.set(e,o);return o};var be=(e,n)=>()=>(n||e((n={exports:{}}).exports,n),n.exports);var se=be(function(ki,L){var f=function(){this.Diff_Timeout=1,this.Diff_EditCost=4,this.Match_Threshold=0.5,this.Match_Distance=1000,this.Patch_DeleteThreshold=0.5,this.Patch_Margin=4,this.Match_MaxBits=32},x=-1,w=1,T=0;f.Diff=function(e,n){return[e,n]};f.prototype.diff_main=function(e,n,t,r){if(typeof r>"u")if(this.Diff_Timeout<=0)r=Number.MAX_VALUE;else r=new Date().getTime()+this.Diff_Timeout*1000;var s=r;if(e==null||n==null)throw Error("Null input. (diff_main)");if(e==n){if(e)return[new f.Diff(T,e)];return[]}if(typeof t>"u")t=!0;var i=t,o=this.diff_commonPrefix(e,n),a=e.substring(0,o);e=e.substring(o),n=n.substring(o),o=this.diff_commonSuffix(e,n);var u=e.substring(e.length-o);e=e.substring(0,e.length-o),n=n.substring(0,n.length-o);var l=this.diff_compute_(e,n,i,s);if(a)l.unshift(new f.Diff(T,a));if(u)l.push(new f.Diff(T,u));return this.diff_cleanupMerge(l),l};f.prototype.diff_compute_=function(e,n,t,r){var s;if(!e)return[new f.Diff(w,n)];if(!n)return[new f.Diff(x,e)];var i=e.length>n.length?e:n,o=e.length>n.length?n:e,a=i.indexOf(o);if(a!=-1){if(s=[new f.Diff(w,i.substring(0,a)),new f.Diff(T,o),new f.Diff(w,i.substring(a+o.length))],e.length>n.length)s[0][0]=s[2][0]=x;return s}if(o.length==1)return[new f.Diff(x,e),new f.Diff(w,n)];var u=this.diff_halfMatch_(e,n);if(u){var l=u[0],c=u[1],d=u[2],g=u[3],m=u[4],p=this.diff_main(l,d,t,r),h=this.diff_main(c,g,t,r);return p.concat([new f.Diff(T,m)],h)}if(t&&e.length>100&&n.length>100)return this.diff_lineMode_(e,n,r);return this.diff_bisect_(e,n,r)};f.prototype.diff_lineMode_=function(e,n,t){var r=this.diff_linesToChars_(e,n);e=r.chars1,n=r.chars2;var s=r.lineArray,i=this.diff_main(e,n,!1,t);this.diff_charsToLines_(i,s),this.diff_cleanupSemantic(i),i.push(new f.Diff(T,""));var o=0,a=0,u=0,l="",c="";while(o<i.length){switch(i[o][0]){case w:u++,c+=i[o][1];break;case x:a++,l+=i[o][1];break;case T:if(a>=1&&u>=1){i.splice(o-a-u,a+u),o=o-a-u;var d=this.diff_main(l,c,!1,t);for(var g=d.length-1;g>=0;g--)i.splice(o,0,d[g]);o=o+d.length}u=0,a=0,l="",c="";break}o++}return i.pop(),i};f.prototype.diff_bisect_=function(e,n,t){var r=e.length,s=n.length,i=Math.ceil((r+s)/2),o=i,a=2*i,u=Array(a),l=Array(a);for(var c=0;c<a;c++)u[c]=-1,l[c]=-1;u[o+1]=0,l[o+1]=0;var d=r-s,g=d%2!=0,m=0,p=0,h=0,y=0;for(var b=0;b<i;b++){if(new Date().getTime()>t)break;for(var v=-b+m;v<=b-p;v+=2){var k=o+v,C;if(v==-b||v!=b&&u[k-1]<u[k+1])C=u[k+1];else C=u[k-1]+1;var D=C-v;while(C<r&&D<s&&e.charAt(C)==n.charAt(D))C++,D++;if(u[k]=C,C>r)p+=2;else if(D>s)m+=2;else if(g){var N=o+d-v;if(N>=0&&N<a&&l[N]!=-1){var R=r-l[N];if(C>=R)return this.diff_bisectSplit_(e,n,C,D,t)}}}for(var S=-b+h;S<=b-y;S+=2){var N=o+S,R;if(S==-b||S!=b&&l[N-1]<l[N+1])R=l[N+1];else R=l[N-1]+1;var _=R-S;while(R<r&&_<s&&e.charAt(r-R-1)==n.charAt(s-_-1))R++,_++;if(l[N]=R,R>r)y+=2;else if(_>s)h+=2;else if(!g){var k=o+d-S;if(k>=0&&k<a&&u[k]!=-1){var C=u[k],D=o+C-k;if(R=r-R,C>=R)return this.diff_bisectSplit_(e,n,C,D,t)}}}}return[new f.Diff(x,e),new f.Diff(w,n)]};f.prototype.diff_bisectSplit_=function(e,n,t,r,s){var i=e.substring(0,t),o=n.substring(0,r),a=e.substring(t),u=n.substring(r),l=this.diff_main(i,o,!1,s),c=this.diff_main(a,u,!1,s);return l.concat(c)};f.prototype.diff_linesToChars_=function(e,n){var t=[],r={};t[0]="";function s(u){var l="",c=0,d=-1,g=t.length;while(d<u.length-1){if(d=u.indexOf(`
|
|
2
|
+
`,c),d==-1)d=u.length-1;var m=u.substring(c,d+1);if(r.hasOwnProperty?r.hasOwnProperty(m):r[m]!==void 0)l+=String.fromCharCode(r[m]);else{if(g==i)m=u.substring(c),d=u.length;l+=String.fromCharCode(g),r[m]=g,t[g++]=m}c=d+1}return l}var i=40000,o=s(e);i=65535;var a=s(n);return{chars1:o,chars2:a,lineArray:t}};f.prototype.diff_charsToLines_=function(e,n){for(var t=0;t<e.length;t++){var r=e[t][1],s=[];for(var i=0;i<r.length;i++)s[i]=n[r.charCodeAt(i)];e[t][1]=s.join("")}};f.prototype.diff_commonPrefix=function(e,n){if(!e||!n||e.charAt(0)!=n.charAt(0))return 0;var t=0,r=Math.min(e.length,n.length),s=r,i=0;while(t<s){if(e.substring(i,s)==n.substring(i,s))t=s,i=t;else r=s;s=Math.floor((r-t)/2+t)}return s};f.prototype.diff_commonSuffix=function(e,n){if(!e||!n||e.charAt(e.length-1)!=n.charAt(n.length-1))return 0;var t=0,r=Math.min(e.length,n.length),s=r,i=0;while(t<s){if(e.substring(e.length-s,e.length-i)==n.substring(n.length-s,n.length-i))t=s,i=t;else r=s;s=Math.floor((r-t)/2+t)}return s};f.prototype.diff_commonOverlap_=function(e,n){var t=e.length,r=n.length;if(t==0||r==0)return 0;if(t>r)e=e.substring(t-r);else if(t<r)n=n.substring(0,t);var s=Math.min(t,r);if(e==n)return s;var i=0,o=1;while(!0){var a=e.substring(s-o),u=n.indexOf(a);if(u==-1)return i;if(o+=u,u==0||e.substring(s-o)==n.substring(0,o))i=o,o++}};f.prototype.diff_halfMatch_=function(e,n){if(this.Diff_Timeout<=0)return null;var t=e.length>n.length?e:n,r=e.length>n.length?n:e;if(t.length<4||r.length*2<t.length)return null;var s=this;function i(p,h,y){var b=p.substring(y,y+Math.floor(p.length/4)),v=-1,k="",C,D,N,R;while((v=h.indexOf(b,v+1))!=-1){var S=s.diff_commonPrefix(p.substring(y),h.substring(v)),_=s.diff_commonSuffix(p.substring(0,y),h.substring(0,v));if(k.length<_+S)k=h.substring(v-_,v)+h.substring(v,v+S),C=p.substring(0,y-_),D=p.substring(y+S),N=h.substring(0,v-_),R=h.substring(v+S)}if(k.length*2>=p.length)return[C,D,N,R,k];else return null}var o=i(t,r,Math.ceil(t.length/4)),a=i(t,r,Math.ceil(t.length/2)),u;if(!o&&!a)return null;else if(!a)u=o;else if(!o)u=a;else u=o[4].length>a[4].length?o:a;var l,c,d,g;if(e.length>n.length)l=u[0],c=u[1],d=u[2],g=u[3];else d=u[0],g=u[1],l=u[2],c=u[3];var m=u[4];return[l,c,d,g,m]};f.prototype.diff_cleanupSemantic=function(e){var n=!1,t=[],r=0,s=null,i=0,o=0,a=0,u=0,l=0;while(i<e.length){if(e[i][0]==T)t[r++]=i,o=u,a=l,u=0,l=0,s=e[i][1];else{if(e[i][0]==w)u+=e[i][1].length;else l+=e[i][1].length;if(s&&s.length<=Math.max(o,a)&&s.length<=Math.max(u,l))e.splice(t[r-1],0,new f.Diff(x,s)),e[t[r-1]+1][0]=w,r--,r--,i=r>0?t[r-1]:-1,o=0,a=0,u=0,l=0,s=null,n=!0}i++}if(n)this.diff_cleanupMerge(e);this.diff_cleanupSemanticLossless(e),i=1;while(i<e.length){if(e[i-1][0]==x&&e[i][0]==w){var c=e[i-1][1],d=e[i][1],g=this.diff_commonOverlap_(c,d),m=this.diff_commonOverlap_(d,c);if(g>=m){if(g>=c.length/2||g>=d.length/2)e.splice(i,0,new f.Diff(T,d.substring(0,g))),e[i-1][1]=c.substring(0,c.length-g),e[i+1][1]=d.substring(g),i++}else if(m>=c.length/2||m>=d.length/2)e.splice(i,0,new f.Diff(T,c.substring(0,m))),e[i-1][0]=w,e[i-1][1]=d.substring(0,d.length-m),e[i+1][0]=x,e[i+1][1]=c.substring(m),i++;i++}i++}};f.prototype.diff_cleanupSemanticLossless=function(e){function n(m,p){if(!m||!p)return 6;var h=m.charAt(m.length-1),y=p.charAt(0),b=h.match(f.nonAlphaNumericRegex_),v=y.match(f.nonAlphaNumericRegex_),k=b&&h.match(f.whitespaceRegex_),C=v&&y.match(f.whitespaceRegex_),D=k&&h.match(f.linebreakRegex_),N=C&&y.match(f.linebreakRegex_),R=D&&m.match(f.blanklineEndRegex_),S=N&&p.match(f.blanklineStartRegex_);if(R||S)return 5;else if(D||N)return 4;else if(b&&!k&&C)return 3;else if(k||C)return 2;else if(b||v)return 1;return 0}var t=1;while(t<e.length-1){if(e[t-1][0]==T&&e[t+1][0]==T){var r=e[t-1][1],s=e[t][1],i=e[t+1][1],o=this.diff_commonSuffix(r,s);if(o){var a=s.substring(s.length-o);r=r.substring(0,r.length-o),s=a+s.substring(0,s.length-o),i=a+i}var u=r,l=s,c=i,d=n(r,s)+n(s,i);while(s.charAt(0)===i.charAt(0)){r+=s.charAt(0),s=s.substring(1)+i.charAt(0),i=i.substring(1);var g=n(r,s)+n(s,i);if(g>=d)d=g,u=r,l=s,c=i}if(e[t-1][1]!=u){if(u)e[t-1][1]=u;else e.splice(t-1,1),t--;if(e[t][1]=l,c)e[t+1][1]=c;else e.splice(t+1,1),t--}}t++}};f.nonAlphaNumericRegex_=/[^a-zA-Z0-9]/;f.whitespaceRegex_=/\s/;f.linebreakRegex_=/[\r\n]/;f.blanklineEndRegex_=/\n\r?\n$/;f.blanklineStartRegex_=/^\r?\n\r?\n/;f.prototype.diff_cleanupEfficiency=function(e){var n=!1,t=[],r=0,s=null,i=0,o=!1,a=!1,u=!1,l=!1;while(i<e.length){if(e[i][0]==T){if(e[i][1].length<this.Diff_EditCost&&(u||l))t[r++]=i,o=u,a=l,s=e[i][1];else r=0,s=null;u=l=!1}else{if(e[i][0]==x)l=!0;else u=!0;if(s&&(o&&a&&u&&l||s.length<this.Diff_EditCost/2&&o+a+u+l==3)){if(e.splice(t[r-1],0,new f.Diff(x,s)),e[t[r-1]+1][0]=w,r--,s=null,o&&a)u=l=!0,r=0;else r--,i=r>0?t[r-1]:-1,u=l=!1;n=!0}}i++}if(n)this.diff_cleanupMerge(e)};f.prototype.diff_cleanupMerge=function(e){e.push(new f.Diff(T,""));var n=0,t=0,r=0,s="",i="",o;while(n<e.length)switch(e[n][0]){case w:r++,i+=e[n][1],n++;break;case x:t++,s+=e[n][1],n++;break;case T:if(t+r>1){if(t!==0&&r!==0){if(o=this.diff_commonPrefix(i,s),o!==0){if(n-t-r>0&&e[n-t-r-1][0]==T)e[n-t-r-1][1]+=i.substring(0,o);else e.splice(0,0,new f.Diff(T,i.substring(0,o))),n++;i=i.substring(o),s=s.substring(o)}if(o=this.diff_commonSuffix(i,s),o!==0)e[n][1]=i.substring(i.length-o)+e[n][1],i=i.substring(0,i.length-o),s=s.substring(0,s.length-o)}if(n-=t+r,e.splice(n,t+r),s.length)e.splice(n,0,new f.Diff(x,s)),n++;if(i.length)e.splice(n,0,new f.Diff(w,i)),n++;n++}else if(n!==0&&e[n-1][0]==T)e[n-1][1]+=e[n][1],e.splice(n,1);else n++;r=0,t=0,s="",i="";break}if(e[e.length-1][1]==="")e.pop();var a=!1;n=1;while(n<e.length-1){if(e[n-1][0]==T&&e[n+1][0]==T){if(e[n][1].substring(e[n][1].length-e[n-1][1].length)==e[n-1][1])e[n][1]=e[n-1][1]+e[n][1].substring(0,e[n][1].length-e[n-1][1].length),e[n+1][1]=e[n-1][1]+e[n+1][1],e.splice(n-1,1),a=!0;else if(e[n][1].substring(0,e[n+1][1].length)==e[n+1][1])e[n-1][1]+=e[n+1][1],e[n][1]=e[n][1].substring(e[n+1][1].length)+e[n+1][1],e.splice(n+1,1),a=!0}n++}if(a)this.diff_cleanupMerge(e)};f.prototype.diff_xIndex=function(e,n){var t=0,r=0,s=0,i=0,o;for(o=0;o<e.length;o++){if(e[o][0]!==w)t+=e[o][1].length;if(e[o][0]!==x)r+=e[o][1].length;if(t>n)break;s=t,i=r}if(e.length!=o&&e[o][0]===x)return i;return i+(n-s)};f.prototype.diff_prettyHtml=function(e){var n=[],t=/&/g,r=/</g,s=/>/g,i=/\n/g;for(var o=0;o<e.length;o++){var a=e[o][0],u=e[o][1],l=u.replace(t,"&").replace(r,"<").replace(s,">").replace(i,"¶<br>");switch(a){case w:n[o]='<ins style="background:#e6ffe6;">'+l+"</ins>";break;case x:n[o]='<del style="background:#ffe6e6;">'+l+"</del>";break;case T:n[o]="<span>"+l+"</span>";break}}return n.join("")};f.prototype.diff_text1=function(e){var n=[];for(var t=0;t<e.length;t++)if(e[t][0]!==w)n[t]=e[t][1];return n.join("")};f.prototype.diff_text2=function(e){var n=[];for(var t=0;t<e.length;t++)if(e[t][0]!==x)n[t]=e[t][1];return n.join("")};f.prototype.diff_levenshtein=function(e){var n=0,t=0,r=0;for(var s=0;s<e.length;s++){var i=e[s][0],o=e[s][1];switch(i){case w:t+=o.length;break;case x:r+=o.length;break;case T:n+=Math.max(t,r),t=0,r=0;break}}return n+=Math.max(t,r),n};f.prototype.diff_toDelta=function(e){var n=[];for(var t=0;t<e.length;t++)switch(e[t][0]){case w:n[t]="+"+encodeURI(e[t][1]);break;case x:n[t]="-"+e[t][1].length;break;case T:n[t]="="+e[t][1].length;break}return n.join("\t").replace(/%20/g," ")};f.prototype.diff_fromDelta=function(e,n){var t=[],r=0,s=0,i=n.split(/\t/g);for(var o=0;o<i.length;o++){var a=i[o].substring(1);switch(i[o].charAt(0)){case"+":try{t[r++]=new f.Diff(w,decodeURI(a))}catch(c){throw Error("Illegal escape in diff_fromDelta: "+a)}break;case"-":case"=":var u=parseInt(a,10);if(isNaN(u)||u<0)throw Error("Invalid number in diff_fromDelta: "+a);var l=e.substring(s,s+=u);if(i[o].charAt(0)=="=")t[r++]=new f.Diff(T,l);else t[r++]=new f.Diff(x,l);break;default:if(i[o])throw Error("Invalid diff operation in diff_fromDelta: "+i[o])}}if(s!=e.length)throw Error("Delta length ("+s+") does not equal source text length ("+e.length+").");return t};f.prototype.match_main=function(e,n,t){if(e==null||n==null||t==null)throw Error("Null input. (match_main)");if(t=Math.max(0,Math.min(t,e.length)),e==n)return 0;else if(!e.length)return-1;else if(e.substring(t,t+n.length)==n)return t;else return this.match_bitap_(e,n,t)};f.prototype.match_bitap_=function(e,n,t){if(n.length>this.Match_MaxBits)throw Error("Pattern too long for this browser.");var r=this.match_alphabet_(n),s=this;function i(C,D){var N=C/n.length,R=Math.abs(t-D);if(!s.Match_Distance)return R?1:N;return N+R/s.Match_Distance}var o=this.Match_Threshold,a=e.indexOf(n,t);if(a!=-1){if(o=Math.min(i(0,a),o),a=e.lastIndexOf(n,t+n.length),a!=-1)o=Math.min(i(0,a),o)}var u=1<<n.length-1;a=-1;var l,c,d=n.length+e.length,g;for(var m=0;m<n.length;m++){l=0,c=d;while(l<c){if(i(m,t+c)<=o)l=c;else d=c;c=Math.floor((d-l)/2+l)}d=c;var p=Math.max(1,t-c+1),h=Math.min(t+c,e.length)+n.length,y=Array(h+2);y[h+1]=(1<<m)-1;for(var b=h;b>=p;b--){var v=r[e.charAt(b-1)];if(m===0)y[b]=(y[b+1]<<1|1)&v;else y[b]=(y[b+1]<<1|1)&v|((g[b+1]|g[b])<<1|1)|g[b+1];if(y[b]&u){var k=i(m,b-1);if(k<=o)if(o=k,a=b-1,a>t)p=Math.max(1,2*t-a);else break}}if(i(m+1,t)>o)break;g=y}return a};f.prototype.match_alphabet_=function(e){var n={};for(var t=0;t<e.length;t++)n[e.charAt(t)]=0;for(var t=0;t<e.length;t++)n[e.charAt(t)]|=1<<e.length-t-1;return n};f.prototype.patch_addContext_=function(e,n){if(n.length==0)return;if(e.start2===null)throw Error("patch not initialized");var t=n.substring(e.start2,e.start2+e.length1),r=0;while(n.indexOf(t)!=n.lastIndexOf(t)&&t.length<this.Match_MaxBits-this.Patch_Margin-this.Patch_Margin)r+=this.Patch_Margin,t=n.substring(e.start2-r,e.start2+e.length1+r);r+=this.Patch_Margin;var s=n.substring(e.start2-r,e.start2);if(s)e.diffs.unshift(new f.Diff(T,s));var i=n.substring(e.start2+e.length1,e.start2+e.length1+r);if(i)e.diffs.push(new f.Diff(T,i));e.start1-=s.length,e.start2-=s.length,e.length1+=s.length+i.length,e.length2+=s.length+i.length};f.prototype.patch_make=function(e,n,t){var r,s;if(typeof e=="string"&&typeof n=="string"&&typeof t>"u"){if(r=e,s=this.diff_main(r,n,!0),s.length>2)this.diff_cleanupSemantic(s),this.diff_cleanupEfficiency(s)}else if(e&&typeof e=="object"&&typeof n>"u"&&typeof t>"u")s=e,r=this.diff_text1(s);else if(typeof e=="string"&&n&&typeof n=="object"&&typeof t>"u")r=e,s=n;else if(typeof e=="string"&&typeof n=="string"&&t&&typeof t=="object")r=e,s=t;else throw Error("Unknown call format to patch_make.");if(s.length===0)return[];var i=[],o=new f.patch_obj,a=0,u=0,l=0,c=r,d=r;for(var g=0;g<s.length;g++){var m=s[g][0],p=s[g][1];if(!a&&m!==T)o.start1=u,o.start2=l;switch(m){case w:o.diffs[a++]=s[g],o.length2+=p.length,d=d.substring(0,l)+p+d.substring(l);break;case x:o.length1+=p.length,o.diffs[a++]=s[g],d=d.substring(0,l)+d.substring(l+p.length);break;case T:if(p.length<=2*this.Patch_Margin&&a&&s.length!=g+1)o.diffs[a++]=s[g],o.length1+=p.length,o.length2+=p.length;else if(p.length>=2*this.Patch_Margin){if(a)this.patch_addContext_(o,c),i.push(o),o=new f.patch_obj,a=0,c=d,u=l}break}if(m!==w)u+=p.length;if(m!==x)l+=p.length}if(a)this.patch_addContext_(o,c),i.push(o);return i};f.prototype.patch_deepCopy=function(e){var n=[];for(var t=0;t<e.length;t++){var r=e[t],s=new f.patch_obj;s.diffs=[];for(var i=0;i<r.diffs.length;i++)s.diffs[i]=new f.Diff(r.diffs[i][0],r.diffs[i][1]);s.start1=r.start1,s.start2=r.start2,s.length1=r.length1,s.length2=r.length2,n[t]=s}return n};f.prototype.patch_apply=function(e,n){if(e.length==0)return[n,[]];e=this.patch_deepCopy(e);var t=this.patch_addPadding(e);n=t+n+t,this.patch_splitMax(e);var r=0,s=[];for(var i=0;i<e.length;i++){var o=e[i].start2+r,a=this.diff_text1(e[i].diffs),u,l=-1;if(a.length>this.Match_MaxBits){if(u=this.match_main(n,a.substring(0,this.Match_MaxBits),o),u!=-1){if(l=this.match_main(n,a.substring(a.length-this.Match_MaxBits),o+a.length-this.Match_MaxBits),l==-1||u>=l)u=-1}}else u=this.match_main(n,a,o);if(u==-1)s[i]=!1,r-=e[i].length2-e[i].length1;else{s[i]=!0,r=u-o;var c;if(l==-1)c=n.substring(u,u+a.length);else c=n.substring(u,l+this.Match_MaxBits);if(a==c)n=n.substring(0,u)+this.diff_text2(e[i].diffs)+n.substring(u+a.length);else{var d=this.diff_main(a,c,!1);if(a.length>this.Match_MaxBits&&this.diff_levenshtein(d)/a.length>this.Patch_DeleteThreshold)s[i]=!1;else{this.diff_cleanupSemanticLossless(d);var g=0,m;for(var p=0;p<e[i].diffs.length;p++){var h=e[i].diffs[p];if(h[0]!==T)m=this.diff_xIndex(d,g);if(h[0]===w)n=n.substring(0,u+m)+h[1]+n.substring(u+m);else if(h[0]===x)n=n.substring(0,u+m)+n.substring(u+this.diff_xIndex(d,g+h[1].length));if(h[0]!==x)g+=h[1].length}}}}}return n=n.substring(t.length,n.length-t.length),[n,s]};f.prototype.patch_addPadding=function(e){var n=this.Patch_Margin,t="";for(var r=1;r<=n;r++)t+=String.fromCharCode(r);for(var r=0;r<e.length;r++)e[r].start1+=n,e[r].start2+=n;var s=e[0],i=s.diffs;if(i.length==0||i[0][0]!=T)i.unshift(new f.Diff(T,t)),s.start1-=n,s.start2-=n,s.length1+=n,s.length2+=n;else if(n>i[0][1].length){var o=n-i[0][1].length;i[0][1]=t.substring(i[0][1].length)+i[0][1],s.start1-=o,s.start2-=o,s.length1+=o,s.length2+=o}if(s=e[e.length-1],i=s.diffs,i.length==0||i[i.length-1][0]!=T)i.push(new f.Diff(T,t)),s.length1+=n,s.length2+=n;else if(n>i[i.length-1][1].length){var o=n-i[i.length-1][1].length;i[i.length-1][1]+=t.substring(0,o),s.length1+=o,s.length2+=o}return t};f.prototype.patch_splitMax=function(e){var n=this.Match_MaxBits;for(var t=0;t<e.length;t++){if(e[t].length1<=n)continue;var r=e[t];e.splice(t--,1);var{start1:s,start2:i}=r,o="";while(r.diffs.length!==0){var a=new f.patch_obj,u=!0;if(a.start1=s-o.length,a.start2=i-o.length,o!=="")a.length1=a.length2=o.length,a.diffs.push(new f.Diff(T,o));while(r.diffs.length!==0&&a.length1<n-this.Patch_Margin){var l=r.diffs[0][0],c=r.diffs[0][1];if(l===w)a.length2+=c.length,i+=c.length,a.diffs.push(r.diffs.shift()),u=!1;else if(l===x&&a.diffs.length==1&&a.diffs[0][0]==T&&c.length>2*n)a.length1+=c.length,s+=c.length,u=!1,a.diffs.push(new f.Diff(l,c)),r.diffs.shift();else{if(c=c.substring(0,n-a.length1-this.Patch_Margin),a.length1+=c.length,s+=c.length,l===T)a.length2+=c.length,i+=c.length;else u=!1;if(a.diffs.push(new f.Diff(l,c)),c==r.diffs[0][1])r.diffs.shift();else r.diffs[0][1]=r.diffs[0][1].substring(c.length)}}o=this.diff_text2(a.diffs),o=o.substring(o.length-this.Patch_Margin);var d=this.diff_text1(r.diffs).substring(0,this.Patch_Margin);if(d!=="")if(a.length1+=d.length,a.length2+=d.length,a.diffs.length!==0&&a.diffs[a.diffs.length-1][0]===T)a.diffs[a.diffs.length-1][1]+=d;else a.diffs.push(new f.Diff(T,d));if(!u)e.splice(++t,0,a)}}};f.prototype.patch_toText=function(e){var n=[];for(var t=0;t<e.length;t++)n[t]=e[t];return n.join("")};f.prototype.patch_fromText=function(e){var n=[];if(!e)return n;var t=e.split(`
|
|
3
|
+
`),r=0,s=/^@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@$/;while(r<t.length){var i=t[r].match(s);if(!i)throw Error("Invalid patch string: "+t[r]);var o=new f.patch_obj;if(n.push(o),o.start1=parseInt(i[1],10),i[2]==="")o.start1--,o.length1=1;else if(i[2]=="0")o.length1=0;else o.start1--,o.length1=parseInt(i[2],10);if(o.start2=parseInt(i[3],10),i[4]==="")o.start2--,o.length2=1;else if(i[4]=="0")o.length2=0;else o.start2--,o.length2=parseInt(i[4],10);r++;while(r<t.length){var a=t[r].charAt(0);try{var u=decodeURI(t[r].substring(1))}catch(l){throw Error("Illegal escape in patch_fromText: "+u)}if(a=="-")o.diffs.push(new f.Diff(x,u));else if(a=="+")o.diffs.push(new f.Diff(w,u));else if(a==" ")o.diffs.push(new f.Diff(T,u));else if(a=="@")break;else if(a==="");else throw Error('Invalid patch mode "'+a+'" in: '+u);r++}}return n};f.patch_obj=function(){this.diffs=[],this.start1=null,this.start2=null,this.length1=0,this.length2=0};f.patch_obj.prototype.toString=function(){var e,n;if(this.length1===0)e=this.start1+",0";else if(this.length1==1)e=this.start1+1;else e=this.start1+1+","+this.length1;if(this.length2===0)n=this.start2+",0";else if(this.length2==1)n=this.start2+1;else n=this.start2+1+","+this.length2;var t=["@@ -"+e+" +"+n+` @@
|
|
4
|
+
`],r;for(var s=0;s<this.diffs.length;s++){switch(this.diffs[s][0]){case w:r="+";break;case x:r="-";break;case T:r=" ";break}t[s+1]=r+encodeURI(this.diffs[s][1])+`
|
|
5
|
+
`}return t.join("").replace(/%20/g," ")};L.exports=f;L.exports.diff_match_patch=f;L.exports.DIFF_DELETE=x;L.exports.DIFF_INSERT=w;L.exports.DIFF_EQUAL=T});class E extends Error{}class Q extends E{util="cluster"}function Ie(e,n){if(n<1)throw new Q("Cluster size cannot be smaller than 1");if(e.length===0)return[];let t=[[]],r=0;for(let s of e)if(t[r].length<n)t[r].push(s);else r+=1,t[r]=[s];return t}function Me(...e){return[].concat(...e)}function Ve(e,n){let t={};for(let r of e){let s=n(r);t[s]=(t[s]??0)+1}return t}function Fe(e,n){let t=[],r=[],s=!1;for(let[i,o]of e.entries()){let a=n(o,i,e);if(a instanceof Promise){if(!s)r=t.map((u)=>[!0,u]),s=!0,t.length=0;r.push(a.then((u)=>[!!u,o]))}else if(s)r.push([!!a,o]);else if(a)t.push(o)}if(s)return Promise.all(r).then((i)=>{let o=[];for(let[a,u]of i)if(a)o.push(u);return o});return t}function $e(e,n,t){let r=[];for(let[s,i]of e.entries())if(n(i,s)){let o=t(i,r.length,s);r.push(o)}return r}function He(e,n){return e.length===0?n:e[0]}function Be(e,n){let t=[[],[]];for(let r of e){let s=n(r)?0:1;t[s].push(r)}return t}function ze(e,n){let t={};for(let r of e){let s=n(r);t[s]??=[],t[s].push(r)}return t}function We(e){return e.length>0}function Xe(e,n){return e.length===0?n:e.at(-1)}function H(e){return typeof e==="function"}function P(e,...n){return H(e)?e(...n):e}class K extends E{util="list"}function tn(e,n,t){let r=typeof n==="number"?e:0,s=typeof n==="number"?n:e,i=r>s;if(t){if(typeof t.step==="number"){if(t.step===0)throw new K("Step cannot be 0, that would cause the list to become infinite");if(i&&t.step>0)throw new K("Given start and end should cause the list to traverse negatively, but step is specified to traverse positively");else if(!i&&t.step<0)throw new K("Given start and end should cause the list to traverse positively, but step is specified to traverse negatively")}}let o=[];while(i?r>=s:r<=s){if(t?.valueMapper!==void 0)o.push(P(t.valueMapper,r));else o.push(r);r+=t?.step??(i?-1:1)}return o}function sn(e,n){let t=[],r=!1;for(let[s,i]of e.entries()){let o=n(i,s,e);if(t.push(o),!r&&o instanceof Promise)r=!0}return r?Promise.all(t):t}function an(e,n,t){if(e.length===0)return;let r=t?.direction??"ASCENDING",s=r==="DESCENDING"?"reduceRight":"reduce";if(n)return e[s]((i,o)=>{let a=n(o);if(a>i.target)return{value:o,target:a};return i},{value:e.at(r==="DESCENDING"?-1:0),target:-1/0}).value;return e[s]((i,o)=>{if(typeof o!=="number")return i;if(o>=i.target)return{value:o,target:o};return i},{value:void 0,target:-1/0}).value}function ln(e,n,t){if(e.length===0)return;let r=t?.direction??"ASCENDING",s=r==="DESCENDING"?"reduceRight":"reduce";if(n)return e[s]((i,o)=>{let a=n(o);if(a<i.target)return{value:o,target:a};return i},{value:e.at(r==="DESCENDING"?-1:0),target:1/0}).value;return e[s]((i,o)=>{if(typeof o!=="number")return i;if(o<=i.target)return{value:o,target:o};return i},{value:void 0,target:1/0}).value}class W extends E{util="overflow"}function pn(e,n){if(n<0)throw new W("Clamp length cannot be smaller than 0");return[e.slice(0,n),e.slice(n)]}function gn(e,n,t,r){let s=r?.direction??"ASCENDING",i=n;if(s==="DESCENDING")for(let o=e.length-1;o!==-1;o--)i=t(i,e[o],o,e);else for(let[o,a]of e.entries())i=t(i,a,o,e);if(r?.result)return r.result(i);return i}class Z extends E{util="select"}function Tn(e,n){if(e.length===0)return[];let t=[],r={list:e,discard(){return{type:"DISCARD"}},keep(){return{type:"KEEP"}},filter(s){return{type:"FILTER",keep:s}},map(s){return{type:"MAP",value:s}},flat(s){return{type:"FLAT",list:s}},spread(...s){return{type:"SPREAD",values:s}}};for(let[s,i]of e.entries()){let o=n({...r,index:s,item:i});switch(o.type){case"DISCARD":break;case"KEEP":{t.push(i);break}case"FILTER":{if(o.keep)t.push(i);break}case"MAP":{t.push(o.value);break}case"FLAT":{t.push(...o.list);break}case"SPREAD":{t.push(...o.values);break}default:{let a=o.type;throw new Z(`Invalid action type: ${a}`)}}}return t}function yn(e){return e.filter((n)=>!!n)}function xn(e,n){let t=0;if(n)for(let r of e){let s=n(r);if(Number.isNaN(s))continue;t+=s}else for(let r of e){if(typeof r==="number"&&!Number.isNaN(r)){t+=r;continue}t+=r?1:0}return t}function kn(e,n,t){let r=(o)=>t?.toKey?.(o)??o,s=e.findIndex((o)=>r(o)===r(n)),i=[...e];if(s===-1)switch(t?.strategy??"APPEND"){case"APPEND":{i.push(n);break}case"PREPEND":{i.unshift(n);break}}else i.splice(s,1);return i}function Rn(...e){let n;for(let t of e)n=t(n);return n}function Nn(...e){return(...n)=>e.reduce((t,r,s)=>{let i=r;return s===0?i(...n):i(t)},void 0)}function Sn(e){setTimeout(()=>{e()},0)}function On(){}function In(e,n){return n(e)}function Mn(e){return e}function X(e){return typeof e==="object"&&!!e&&!Array.isArray(e)}function Fn(e){if(e==null)return!0;if(typeof e==="string")return e.length===0;if(X(e))return Object.keys(e).length===0;if(Array.isArray(e))return e.length===0;return!1}function $n(e){return e===null}function Hn(e){return e==null}function Bn(e){if(e===null)return!0;switch(typeof e){case"boolean":case"number":case"string":case"symbol":case"undefined":return!0;default:return!1}}function zn(e){return e instanceof Promise}function Wn(e){return!!e&&typeof e==="object"&&"then"in e&&typeof e.then==="function"}function Xn(e){return e===void 0}function et(e,n,t){let r=String(e);if(r in n)return P(n[r]);if(H(t))return t(r);return t}function tt(e,...n){try{let t=e(...n);if(t instanceof Promise)return t.then((r)=>({success:!0,value:r}),(r)=>({success:!1,error:r}));return{success:!0,value:t}}catch(t){return{success:!1,error:t}}}function rt(...e){let[n,t]=e;if(e.length>1)return n.success?n.value:t;if(n.success)return n.value;throw n.error}function st(e){switch(typeof e){case"string":throw Error(e);case"function":throw e();default:throw e}}class M extends E{util="range"}class A{static#o=/^(\d+?(?:\.\d+)?)?(>)?\.\.(=)?(\d+?(?:\.\d+)?)?$/;static from(e){return new A({start:e.#e,inclusiveStart:e.#i,end:e.#n,inclusiveEnd:e.#t,step:e.#r,mapper:e.#s})}#e;#i;#n;#t;#r;#s;constructor(e){if(e===void 0||typeof e==="string"){let t=(e??"..").match(A.#o);if(!t)throw new M("Got a range string, but given range string is not valid");let r=t[1]?Number.parseFloat(t[1]):null,s=!t[2],i=!!t[3],o=t[4]?Number.parseFloat(t[4]):null;if(this.#i=s,this.#t=i,typeof r==="number")this.#e=r;if(typeof o==="number")this.#n=o}else{if(typeof e.start==="number")this.#e=e.start;if(typeof e.end==="number")this.#n=e.end;if(typeof e.step==="number")this.#r=e.step;this.#i=e.inclusiveStart??!0,this.#t=e.inclusiveEnd??!1,this.#s=e.mapper}}get details(){let e=this.#e,n=this.#i,t=this.#n,r=this.#t,s=this.#r,i=this.#s;return{get start(){return e},get inclusiveStart(){return n},get end(){return t},get inclusiveEnd(){return r},get step(){return s},get mapper(){return i}}}start(e,n=this.#i){return new A({start:e,inclusiveStart:n,end:this.#n,inclusiveEnd:this.#t,step:this.#r,mapper:this.#s})}inclusiveStart(e){return new A({start:this.#e,inclusiveStart:e,end:this.#n,inclusiveEnd:this.#t,step:this.#r,mapper:this.#s})}end(e,n=this.#t){return new A({start:this.#e,inclusiveStart:this.#i,end:e,inclusiveEnd:n,step:this.#r,mapper:this.#s})}inclusiveEnd(e){return new A({start:this.#e,inclusiveStart:this.#i,end:this.#n,inclusiveEnd:e,step:this.#r,mapper:this.#s})}step(e){return new A({start:this.#e,inclusiveStart:this.#i,end:this.#n,inclusiveEnd:this.#t,step:e,mapper:this.#s})}map(e){return new A({start:this.#e,inclusiveStart:this.#i,end:this.#n,inclusiveEnd:this.#t,step:this.#r,mapper:e})}includes(e){if(this.#i&&e===this.#e)return!0;if(this.#t&&e===this.#n)return!0;let n=typeof this.#e==="number"&&typeof this.#n==="number"?this.#n>this.#e:!0,t=n?this.#e:this.#n,r=n?this.#n:this.#e;if(typeof t==="number"&&typeof r==="number")return e>t&&e<r;if(typeof t==="number")return e>t;if(typeof r==="number")return e<r;return!0}excludes(e){if(!this.#i&&e===this.#e)return!0;if(!this.#t&&e===this.#n)return!0;let n=typeof this.#e==="number"&&typeof this.#n==="number"?this.#n>this.#e:!0,t=n?this.#e:this.#n,r=n?this.#n:this.#e;if(typeof t==="number"&&typeof r==="number")return e<t||e>r;if(typeof t==="number")return e<t;if(typeof r==="number")return e>r;return!1}*[Symbol.iterator](){if(typeof this.#e!=="number")throw new M("A range must have a start value defined before it becomes iterable, if it isn't defined it can only be used for checking values");if(typeof this.#n!=="number")throw new M("A range must have a end value defined before it becomes iterable, if it isn't defined it can only be used for checking values");let e=this.#e,n=this.#n,t=e>n;if(typeof this.#r==="number"){if(this.#r===0)throw new M("Step cannot be 0, that would cause the range to become infinite");if(t&&this.#r>0)throw new M("Given start and end should cause the range to traverse negatively, but step is specified to traverse positively");else if(!t&&this.#r<0)throw new M("Given start and end should cause the range to traverse positively, but step is specified to traverse negatively")}let r=this.#r??(t?-1:1),s=()=>{if(t){if(this.#t)return e>=n;return e>n}if(this.#t)return e<=n;return e<n};if(!this.#i)e+=r;while(s()){if(this.#s!==void 0)yield P(this.#s,e);else yield e;e+=r}}toArray(){return Array.from(this)}clone(){return A.from(this)}}function lt(...e){if(Array.isArray(e[0])){let[o,...a]=e,u=String.raw(o,...a).trim();return new A(u)}let[n,t,r]=e;if(typeof n==="string"){if(typeof t==="number")throw new M("cannot define a end number when a range string is used");let o=new A(n);if(t){if(typeof t.step==="number")o=o.step(t.step);if(typeof t.valueMapper<"u")o=o.map(t.valueMapper);if(typeof t.inclusiveStart==="boolean")o=o.inclusiveStart(t.inclusiveStart);if(typeof t.inclusiveEnd==="boolean")o=o.inclusiveEnd(t.inclusiveEnd)}return o}let s=typeof n==="number"||n===null?typeof t==="number"||t===null?n:0:void 0,i=typeof t==="number"||t===null?t:n;return new A({start:s,inclusiveStart:r?.inclusiveStart,end:i,inclusiveEnd:r?.inclusiveEnd??!0,step:r?.step,mapper:r?.valueMapper})}function ft(e){return Object.isFrozen(e)}function pt(e,n=!1){let t=(i,o)=>{let a=(u)=>o&&u&&typeof u==="object"?t(u,o):u;if(i instanceof Map)return new Map(Array.from(i,([u,l])=>[a(u),a(l)]));if(i instanceof Set)return new Set(Array.from(i,a));return Array.isArray(i)?i.map(a):Object.fromEntries(Object.entries(i).map(([u,l])=>[u,a(l)]))},r=t(e,n);if(!n)return Object.freeze(r);let s=(i)=>{let o=(a)=>{if(a&&typeof a==="object")s(a)};if(i instanceof Map)for(let[a,u]of i)o(a),o(u);else if(i instanceof Set)for(let a of i)o(a);else for(let a of Array.isArray(i)?i:Object.values(i))o(a);return Object.freeze(i)};return s(r)}async function J(e){return new Promise((n)=>{let t=Math.max(e,0);setTimeout(n,t)})}class Y extends E{util="timeout"}class j extends Error{constructor(e){super(`The operation was timed out after ${e.toString()}ms`);this.name="TimeoutError"}}async function ht(e,n,t){if(n<0)throw new Y("Timeout delay cannot be smaller than 0");let r=new AbortController,s=typeof e==="function"?e(r.signal):e;return new Promise((i,o)=>{let a=setTimeout(()=>{r.abort();try{t?.onTimeout?.(n)}catch(u){o(u);return}o(new j(n))},n);s.then((u)=>{clearTimeout(a),i(u)}).catch((u)=>{clearTimeout(a),o(u)})})}function Tt(e){return e instanceof j}function yt(e){if(e instanceof Map)return Array.from(e.values());if(typeof e[Symbol.iterator]==="function")return Array.from(e);return Object.values(e)}function wt(e,n){return(...t)=>{let r=P(n,...t);return e(...r)}}class ee extends E{util="retry"}async function Et(e,n){let t=n?.attempts??3,r=n?.backoff??!1,s=n?.delay??1000,i=0;while(!0){i+=1;try{return await e()}catch(o){if(i>=t)throw new ee("Callback failed too often, stopping retry loop",{cause:o});else n?.onRetry?.(o,i),await J(s)}if(r)s*=2}}async function Dt(e){await e?.()}function At(e){if(!Number.isInteger(e)||e<=1||e>2&&e%2===0)return!1;let n=Math.sqrt(e);for(let t=3;t<=n;t+=2)if(e%t===0)return!1;return!0}function _t(e,n){return(e%n+n)%n||0}function Pt(e,n,t){if(e>t)return NaN;if(e<=n&&n<=t)return n;if(n<e)return e;if(n>t)return t;return NaN}function Ut(e){if(Number.isNaN(e)||!Number.isFinite(e))return!1;return!Number.isInteger(e)}function Lt(e){return(e%2+2)%2===0}function Kt(e){return Number.isInteger(e)}function Gt(e){return(e%2+2)%2===1}function jt(e){return-Math.abs(e)}function Bt(e){return e<0||Object.is(e,-0)}function zt(e){return Math.abs(e)}function Qt(e){return e>0||Object.is(e,0)}function Zt(e){if(Number.isNaN(e)||e===0)return 0;return Math.sign(e)}function Jt(e,n=0){let t;switch(typeof e){case"boolean":{t=e?1:0;break}case"number":case"bigint":{t=Number.parseFloat(e.toString());break}case"string":{t=Number.parseFloat(e);break}default:return n}if(Number.isNaN(t)||!Number.isFinite(t))return n;return t}function er(e,n=0){let t=Math.trunc(n),r;switch(typeof e){case"boolean":{r=e?1:0;break}case"number":case"bigint":{r=Number.parseInt(e.toString(),10);break}case"string":{r=Number.parseInt(e,10);break}default:return t}if(Number.isNaN(r)||!Number.isFinite(r))return t;return r}function tr(e,n=0){if(n===0)return Math.trunc(e);if(n<0||n>100)throw RangeError("Fraction digits must be between 0 and 100");let[t,r=""]=e.toString().split(".");return Number.parseFloat(`${t}.${r.slice(0,n)}`)}function ir(e){return Object.entries(e)}function or(e,n){let t=Object.getOwnPropertyDescriptors(e);for(let s of Reflect.ownKeys(n))delete t[s];let r=Object.create(Object.getPrototypeOf(e),t);return Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)),r}function ur(e){return Object.keys(e)}function cr(e,n){let t={...e},r=Array.isArray(n)?n:[n];for(let s of r)delete t[s];return t}function pr(e,n){let t={},r=Array.isArray(n)?n:[n];for(let s of r)t[s]=e[s];return t}function G(e){let r;if(e<256)r=crypto.getRandomValues(new Uint8Array(1))[0];else if(e<65536)r=crypto.getRandomValues(new Uint16Array(1))[0];else r=crypto.getRandomValues(new Uint32Array(1))[0];return r%e}function hr(e){if(e.length===0)return;return e[G(e.length)]}function br(){return crypto.getRandomValues(new Uint8Array(1))[0]<127.5}function vr(e=0,n=1){if(e>n)return NaN;if(e===n)return e;let t=n-e;return Math.random()*t+e}function kr(e){let n=[...e];for(let t=n.length-1;t!==1;t-=1){let r=G(t);[n[r],n[t]]=[n[t],n[r]]}return n}function Rr(e=8,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"){if(n.length<=0)return"";let t=n.length,r=Math.max(Math.floor(Math.log(t)/Math.log(8)),1),s=crypto.getRandomValues(new Uint8Array(e*r)),i="",o=0;for(let a=0;a<e;a+=1){let u=0,l=o+r;while(o<l)u+=s[o],o+=1;u%=t,i+=n[u]}return i}function Nr(){return"ffffffff-ffff-ffff-ffff-ffffffffffff"}function Sr(){return"00000000-0000-0000-0000-000000000000"}function ye(){let e=new Uint8Array(16);return crypto.getRandomValues(e)}function U(e){let n=e?.random??e?.rng?.()??ye();if(n.length<16)return null;return n}function V(e){let n=[];for(let r=0;r<256;++r)n.push((r+256).toString(16).slice(1));return(n[e[0]]+n[e[1]]+n[e[2]]+n[e[3]]+"-"+n[e[4]]+n[e[5]]+"-"+n[e[6]]+n[e[7]]+"-"+n[e[8]]+n[e[9]]+"-"+n[e[10]]+n[e[11]]+n[e[12]]+n[e[13]]+n[e[14]]+n[e[15]]).toLowerCase()}class ne extends E{util="uuidV1"}function Pr(e){let n=U(e);if(!n)throw new ne("Random byte length must at least be 16");let t=(e?.milliseconds??Date.now())+12219292800000,r=e?.nanoseconds??0,s=e?.clockSequence??(n[8]<<8|n[9])&16383,i=new Uint8Array(16),o=e?.node??n.slice(10,16);if(!e?.node)o[0]|=1;let a=(t&268435455)*1e4+r,u=a>>>0;i[0]=u>>>24&255,i[1]=u>>>16&255,i[2]=u>>>8&255,i[3]=u&255;let l=(t/268435456|0)*625+(a/4294967296|0)&268435455;i[4]=l>>>8&255,i[5]=l&255,i[6]=l>>>24&15|16,i[7]=l>>>16&255,i[8]=s>>>8|128,i[9]=s&255;for(let c=0;c<6;c+=1)i[10+c]=o[c];return V(i)}class te extends E{util="uuidV4"}function Lr(e){if(!e&&crypto&&"randomUUID"in crypto&&typeof crypto.randomUUID==="function")return crypto.randomUUID();let n=U(e);if(!n)throw new te("Random byte length must at least be 16");return n[6]=n[6]&15|64,n[8]=n[8]&63|128,V(n)}class re extends E{util="uuidV7"}function Gr(e){let n=U(e);if(!n)throw new re("Random byte length must at least be 16");let t=e?.milliseconds??Date.now(),r=e?.sequence??(n[6]&127)<<24|n[7]<<16|n[8]<<8|n[9],s=new Uint8Array(16);return s[0]=t/1099511627776&255,s[1]=t/4294967296&255,s[2]=t/16777216&255,s[3]=t/65536&255,s[4]=t/256&255,s[5]=t&255,s[6]=112|r>>>28&15,s[7]=r>>>20&255,s[8]=128|r>>>14&63,s[9]=r>>>6&255,s[10]=r<<2&255|n[10]&3,s[11]=n[11],s[12]=n[12],s[13]=n[13],s[14]=n[14],s[15]=n[15],V(s)}function ie(e,n){if(n?.parser)return n.parser(e);let t=n?.groupNumbers??!1,r=n?.groupUppercaseLetters??!0,s=[],i=/[A-Z]/,o=/[0-9]/,a=/[\s-_]/,u="",l=()=>{s.push(u),u=""};for(let c of e.trim()){let d=u.at(-1);if(d===void 0){if(a.test(c))continue;u+=c;continue}if(a.test(c)){l();continue}if(t){if(o.test(c)){if(o.test(d)){u+=c;continue}l(),u+=c;continue}else if(o.test(d)){l(),u+=c;continue}}if(i.test(c)){if(r&&i.test(d)){u+=c;continue}l(),u+=c;continue}let g=u.at(-2);if(r&&i.test(d)&&g!==void 0&&i.test(g))s.push(u.slice(0,-1)),u=d;u+=c}if(u.length>0)l();return s}function O(e,n){let t=ie(e,n),r=t.length-1;return t.reduce((s,i,o)=>{if(s+=n.transform(i,o),o!==r)s+=n.seperator;return s},"")}function Qr(e,n){return O(e,{...n,seperator:"",transform:(t,r)=>{if(r===0)return t.toLowerCase();return`${t.slice(0,1).toUpperCase()}${t.slice(1).toLowerCase()}`}})}function Zr(e){return`${e.slice(0,1).toUpperCase()}${e.slice(1)}`}function Yr(e,n){return O(e,{...n,seperator:"-",transform:(t)=>`${t.slice(0,1).toUpperCase()}${t.slice(1).toLowerCase()}`})}function ve(e,n){return O(e,{...n,seperator:"-",transform:(t)=>n?.screaming?t.toUpperCase():t.toLowerCase()})}function ti(e,n){return ve(e,{...n,screaming:!0})}function ii(e){return e.toLowerCase()}function ai(e,n){return O(e,{...n,seperator:"",transform:(t)=>`${t.slice(0,1).toUpperCase()}${t.slice(1)}`})}function xe(e,n){return O(e,{...n,seperator:"_",transform:(t)=>n?.screaming?t.toUpperCase():t.toLowerCase()})}function ci(e,n){return xe(e,{...n,screaming:!0})}function di(e,n){return O(e,{...n,seperator:" ",transform:(t)=>`${t.slice(0,1).toUpperCase()}${t.slice(1)}`})}function mi(e){return`${e.slice(0,1).toLowerCase()}${e.slice(1)}`}function Ti(e){return e.toUpperCase()}function yi(e,n){let t=new URL(e),r=Object.fromEntries(t.searchParams.entries());if(n){let s={};for(let i in n)s[i]=n[i](r[i]);return s}return r}function xi(e){return e.normalize().toLowerCase().replace(/[^\w ]+/g,"").replace(/ +/g,"-")}var I=Te(se(),1),we=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),ke=new Set(["a","abbr","b","bdi","bdo","br","button","cite","code","data","dfn","em","i","img","input","kbd","label","mark","q","rp","rt","ruby","s","samp","select","small","span","strong","sub","sup","textarea","time","u","var","wbr"]);function Ce(e,n){if(e.startsWith("<!--",n)){let s=e.indexOf("-->",n+4);return s===-1?-1:s+2}let t=null,r=n;for(let s of e.slice(n+1)){if(r+=1,t){if(s===t)t=null;continue}if(s==='"'||s==="'"){t=s;continue}if(s===">")return r}return-1}function Re(e){let n=[],t=0;while(t<e.length){if(e[t]==="<"){let i=Ce(e,t);if(i===-1){n.push({kind:"text",value:e.slice(t)});break}n.push({kind:"tag",value:e.slice(t,i+1)}),t=i+1;continue}let r=e.indexOf("<",t),s=r===-1?e.length:r;n.push({kind:"text",value:e.slice(t,s)}),t=s}return n}function Ee(e){let n=/^<\/?\s*([a-zA-Z][a-zA-Z0-9:-]*)/.exec(e);return n?n[1].toLowerCase():""}function oe(e){let n=[],t=[],r=()=>t.length?t[t.length-1].children:n;for(let s of Re(e)){if(s.kind==="text"){if(s.value)r().push({kind:"text",text:s.value});continue}let i=s.value;if(i.startsWith("<!")){r().push({kind:"element",tag:"",openTag:i,closeTag:"",children:[]});continue}let o=Ee(i);if(i.startsWith("</")){let u=-1;for(let c=t.length-1;c>=0;c-=1)if(t[c].tag===o){u=c;break}if(u===-1){r().push({kind:"text",text:i});continue}let l=t[u];while(t.length>u)t.pop();l.closeTag=i;continue}let a={kind:"element",tag:o,openTag:i,closeTag:"",children:[]};if(r().push(a),!/\/\s*>$/.test(i)&&!we.has(o))t.push(a)}return n}function B(e){return ke.has(e)?"INLINE":"BLOCK"}function ae(e){if(e.kind==="text")return e.text;return`${e.openTag}${e.children.map(ae).join("")}${e.closeTag}`}function ue(e){if(e.kind==="text")return`T:${e.text}`;return`E:${e.openTag}${e.children.map(ue).join("")}${e.closeTag}`}function le(e){switch(e){case I.default.DIFF_EQUAL:return"EQUAL";case I.default.DIFF_INSERT:return"INSERT";case I.default.DIFF_DELETE:return"DELETE";default:throw Error("Got invalid difference marker to determine type")}}function Ne({oldItems:e,newItems:n,key:t}){let r=new Map,s=33,i=()=>{if(s===55296)s=57344;let p=String.fromCharCode(s);return s+=1,p},o=(p)=>{let h="";for(let y of p){let b=t(y),v=r.get(b);if(v===void 0)v=i(),r.set(b,v);h+=v}return h},a=o(e),u=o(n),c=new I.default().diff_main(a,u),d=[],g=0,m=0;for(let[p,h]of c)for(let y of h)if(p===I.default.DIFF_EQUAL)d.push({type:"EQUAL",oldItem:e[g],newItem:n[m]}),g+=1,m+=1;else if(p===I.default.DIFF_DELETE)d.push({type:"DELETE",oldItem:e[g]}),g+=1;else d.push({type:"INSERT",newItem:n[m]}),m+=1;return d}function De(e,n){let t=new I.default,r=t.diff_main(e,n);return t.diff_cleanupSemantic(r),r.map(([s,i])=>({type:le(s),content:i,context:"INLINE"}))}function F(e,n){if(e.kind==="text")return{type:n,content:e.text,context:"INLINE"};return{type:n,content:ae(e),context:B(e.tag)}}function ce(e,n){let t=Ne({oldItems:e,newItems:n,key:ue}),r=[];for(let s=0;s<t.length;s+=1){let i=t[s];if(i.type==="EQUAL"){r.push(F(i.oldItem,"EQUAL"));continue}let o=t[s+1];if(i.type==="DELETE"&&o?.type==="INSERT"){let a=i.oldItem,u=o.newItem;if(a.kind==="element"&&u.kind==="element"&&a.tag===u.tag&&a.openTag===u.openTag&&a.closeTag===u.closeTag){if(r.push({type:"EQUAL",content:a.openTag,context:B(a.tag)},...ce(a.children,u.children)),a.closeTag)r.push({type:"EQUAL",content:a.closeTag,context:B(a.tag)});s+=1;continue}if(a.kind==="text"&&u.kind==="text"){r.push(...De(a.text,u.text)),s+=1;continue}r.push(F(a,"DELETE"),F(u,"INSERT")),s+=1;continue}if(i.type==="DELETE"){r.push(F(i.oldItem,"DELETE"));continue}r.push(F(i.newItem,"INSERT"))}return r}function Se(e){let n=[];for(let t of e){let r=n[n.length-1];if(r&&r.type===t.type&&r.context===t.context){r.content+=t.content;continue}n.push({...t})}return n}function Ci(e,n,t){let r=t?.htmlAware??!1,s=t?.raw??!1,i=[];if(r){let o=oe(e),a=oe(n);i.push(...Se(ce(o,a)))}else{let o=new I.default,a=o.diff_main(e,n);o.diff_cleanupSemantic(a);for(let[u,l]of a)i.push({content:l,type:le(u),context:"UNKNOWN"})}if(!s){let o="",a=["",""],u=["",""],l=['<span data-diff="insert">',"</span>"],c=['<div data-diff="insert">',"</div>"],d=['<span data-diff="delete">',"</span>"],g=['<div data-diff="delete">',"</div>"],m=(p,h)=>{let{equal:y,insert:b,delete:v}=h;if(typeof p.equal==="string")y=[p.equal,p.equal];else if(p.equal)y=p.equal;if(typeof p.insert==="string")b=[p.insert,p.insert];else if(p.insert)b=p.insert;if(typeof p.delete==="string")v=[p.delete,p.delete];else if(p.delete)v=p.delete;return{equalTags:y,insertTags:b,deleteTags:v}};if(t&&"tags"in t&&t.tags){if("inlineContext"in t.tags||"blockContext"in t.tags){if(t.tags.inlineContext){let p=m(t.tags.inlineContext,{equal:["",""],insert:['<span data-diff="insert">',"</span>"],delete:['<span data-diff="delete">',"</span>"]});a=p.equalTags,l=p.insertTags,d=p.deleteTags}if(t.tags.blockContext){let p=m(t.tags.blockContext,{equal:["",""],insert:['<div data-diff="insert">',"</div>"],delete:['<div data-diff="delete">',"</div>"]});u=p.equalTags,c=p.insertTags,g=p.deleteTags}}else if("equal"in t.tags||"insert"in t.tags||"delete"in t.tags)if(r){let p=m(t.tags,{equal:["",""],insert:['<span data-diff="insert">',"</span>"],delete:['<span data-diff="delete">',"</span>"]}),h=m(t.tags,{equal:["",""],insert:['<div data-diff="insert">',"</div>"],delete:['<div data-diff="delete">',"</div>"]});a=p.equalTags,u=h.equalTags,l=p.insertTags,c=h.insertTags,d=p.deleteTags,g=h.deleteTags}else{let p=m(t.tags,{equal:["",""],insert:['<span data-diff="insert">',"</span>"],delete:['<span data-diff="delete">',"</span>"]});a=p.equalTags,u=p.equalTags,l=p.insertTags,c=p.insertTags,d=p.deleteTags,g=p.deleteTags}}for(let p of i){let h,y;switch(p.type){case"EQUAL":{switch(p.context){case"BLOCK":{h=u[0],y=u[1];break}case"INLINE":case"UNKNOWN":{h=a[0],y=a[1];break}}break}case"INSERT":{switch(p.context){case"BLOCK":{h=c[0],y=c[1];break}case"INLINE":case"UNKNOWN":{h=l[0],y=l[1];break}}break}case"DELETE":{switch(p.context){case"BLOCK":{h=g[0],y=g[1];break}case"INLINE":case"UNKNOWN":{h=d[0],y=d[1];break}}break}}o+=`${h}${p.content}${y}`}return o}return i}export{Q as ClusterUtilError,K as ListUtilError,W as OverflowUtilError,A as Range,M as RangeUtilError,ee as RetryUtilError,Z as SelectUtilError,j as TimeoutError,Y as TimeoutUtilError,E as UtilError,ne as UuidV1UtilError,te as UuidV4UtilError,re as UuidV7UtilError,Qr as camelCase,Zr as capitalize,Rn as chain,Pt as clamp,Ie as cluster,Nn as compose,P as compute,Me as concat,Ve as counting,O as customCase,Sn as defer,hr as draw,ir as entries,or as extend,Fe as filter,$e as filterMap,He as first,Be as fork,ze as group,We as hasItems,Yr as httpHeaderCase,Mn as identity,H as isComputation,Ut as isDecimal,Fn as isEmpty,Lt as isEven,Kt as isInteger,Bt as isNegative,$n as isNull,Hn as isNullish,X as isObject,Gt as isOdd,Qt as isPositive,At as isPrime,Bn as isPrimitive,zn as isPromise,Wn as isPromiseLike,ft as isReadOnly,Tt as isTimeoutError,Xn as isUndefined,ve as kebabCase,ur as keys,Xe as last,tn as list,ii as lowerCase,sn as map,et as match,an as max,br as maybe,ln as min,_t as mod,jt as negative,On as noop,cr as omit,pn as overflow,yi as parseUrlParams,ai as pascalCase,pr as pick,In as pipe,zt as positive,wt as preset,st as raise,vr as random,lt as range,pt as readOnly,gn as reduce,Et as retry,tt as safe,ti as screamingKebabCase,ci as screamingSnakeCase,Tn as select,kr as shuffle,yn as sift,Zt as sign,J as sleep,xi as slug,xe as snakeCase,xn as sum,Dt as task,Ci as textDifference,ht as timeout,di as titleCase,Jt as toFloat,er as toInt,kn as toggle,Yr as trainCase,tr as trunc,Rr as uid,mi as uncapitalize,rt as unwrap,Ti as upperCase,Lr as uuid,Nr as uuidMax,Sr as uuidNil,Pr as uuidV1,Lr as uuidV4,Gr as uuidV7,Pr as v1,Lr as v4,Gr as v7,yt as values};
|
package/dist/misc/index.d.ts
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
1
|
+
export * from "./utils/compute";
|
|
2
|
+
export * from "./utils/identity";
|
|
3
|
+
export * from "./utils/isEmpty";
|
|
4
|
+
export * from "./utils/isNull";
|
|
5
|
+
export * from "./utils/isNullish";
|
|
6
|
+
export * from "./utils/isPrimitive";
|
|
7
|
+
export * from "./utils/isPromise";
|
|
8
|
+
export * from "./utils/isPromiseLike";
|
|
9
|
+
export * from "./utils/isUndefined";
|
|
10
|
+
export * from "./utils/match";
|
|
11
|
+
export * from "./utils/option";
|
|
12
|
+
export * from "./utils/raise";
|
|
13
|
+
export * from "./utils/range";
|
|
14
|
+
export * from "./utils/readOnly";
|
|
15
|
+
export * from "./utils/sleep";
|
|
16
|
+
export * from "./utils/timeout";
|
|
17
|
+
export * from "./utils/values";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if the given value is null.
|
|
3
|
+
*
|
|
4
|
+
* The time complexity for this is `O(1)`.
|
|
5
|
+
*
|
|
6
|
+
* @param {?} value The value to check if it is null
|
|
7
|
+
* @returns {boolean} A boolean that signals if the given value is null
|
|
8
|
+
*/
|
|
9
|
+
export declare function isNull(value: unknown): value is null;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if the given value is nullish.
|
|
3
|
+
*
|
|
4
|
+
* The following types are considered nullish:
|
|
5
|
+
* - `null`
|
|
6
|
+
* - `undefined`
|
|
7
|
+
*
|
|
8
|
+
* The time complexity for this is `O(1)`.
|
|
9
|
+
*
|
|
10
|
+
* @param {?} value The value to check if it is nullish
|
|
11
|
+
* @returns {boolean} A boolean that signals if the given value is nullish
|
|
12
|
+
*/
|
|
13
|
+
export declare function isNullish(value: unknown): value is undefined | null;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if the given value is a promise.
|
|
3
|
+
*
|
|
4
|
+
* The time complexity for this is `O(1)`.
|
|
5
|
+
*
|
|
6
|
+
* @param {?} value The value to check if it is a promise
|
|
7
|
+
* @returns {boolean} A boolean that signals if the given value is a promise
|
|
8
|
+
*/
|
|
9
|
+
export declare function isPromise(value: unknown): value is Promise<unknown>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if the given value is promise-like.
|
|
3
|
+
*
|
|
4
|
+
* The time complexity for this is `O(1)`.
|
|
5
|
+
*
|
|
6
|
+
* @param {?} value The value to check if it is a promise
|
|
7
|
+
* @returns {boolean} A boolean that signals if the given value is a promise
|
|
8
|
+
*/
|
|
9
|
+
export declare function isPromiseLike(value: unknown): value is PromiseLike<unknown>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if the given value is undefined.
|
|
3
|
+
*
|
|
4
|
+
* The time complexity for this is `O(1)`.
|
|
5
|
+
*
|
|
6
|
+
* @param {?} value The value to check if it is undefined
|
|
7
|
+
* @returns {boolean} A boolean that signals if the given value is undefined
|
|
8
|
+
*/
|
|
9
|
+
export declare function isUndefined(value: unknown): value is undefined;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type Computable } from "../compute";
|
|
2
|
+
export type MatchTarget = string | number | boolean | bigint | null | undefined;
|
|
3
|
+
export type MatchClause<T extends MatchTarget> = Partial<Record<`${T}`, Computable<unknown>>>;
|
|
4
|
+
type ComputedValue<C> = C extends Computable<infer V> ? V : never;
|
|
5
|
+
/**
|
|
6
|
+
* Matches a value to a clause that return a value
|
|
7
|
+
* and returns a fallback if none of the cases match.
|
|
8
|
+
*
|
|
9
|
+
* The time complexity for this is `O(1)`.
|
|
10
|
+
*
|
|
11
|
+
* @template {MatchTarget} T
|
|
12
|
+
* @template {MatchClause<T>} C
|
|
13
|
+
* @template F
|
|
14
|
+
* @param value The target value to match
|
|
15
|
+
* @param clause Clause cases to check `value` against
|
|
16
|
+
* @param fallback A fallback if no case in `clause` matches
|
|
17
|
+
* @returns {ComputedValue<C[keyof C]> | F | undefined}
|
|
18
|
+
*/
|
|
19
|
+
export declare function match<const T extends MatchTarget, const C extends Required<MatchClause<T>>>(value: T, clause: C): ComputedValue<C[keyof C]>;
|
|
20
|
+
export declare function match<const T extends MatchTarget, const C extends MatchClause<T>>(value: T, clause: C): ComputedValue<C[keyof C]> | undefined;
|
|
21
|
+
export declare function match<const T extends MatchTarget, const C extends MatchClause<T>, const F>(value: T, clause: C, fallback: Computable<F, [value: `${Exclude<T, keyof C>}`]>): ComputedValue<C[keyof C]> | F;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { Promisable } from "~/types";
|
|
2
|
+
/**
|
|
3
|
+
* A value that represents a wrapped result with varying success.
|
|
4
|
+
*
|
|
5
|
+
* @template T
|
|
6
|
+
*
|
|
7
|
+
* @see {@link safe} for executing a callback that returns an option
|
|
8
|
+
* @see {@link uwnrap} for a utility that handles option values
|
|
9
|
+
*/
|
|
10
|
+
export type Option<T> = {
|
|
11
|
+
success: true;
|
|
12
|
+
value: T;
|
|
13
|
+
error?: never;
|
|
14
|
+
} | {
|
|
15
|
+
success: false;
|
|
16
|
+
value?: never;
|
|
17
|
+
error: unknown;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Executes the given callback and returns an option of the result.
|
|
21
|
+
*
|
|
22
|
+
* If a value is returned, the success of the option is `true`.
|
|
23
|
+
* If an error is thrown, the success of the option is `false`.
|
|
24
|
+
*
|
|
25
|
+
* If the callback returns a promise, a promise of an option is returned instead.
|
|
26
|
+
*
|
|
27
|
+
* The time complexity for this is `O(1)`.
|
|
28
|
+
*
|
|
29
|
+
* @template T
|
|
30
|
+
* @template {?[]} [Args=never[]]
|
|
31
|
+
* @param {(...args: Args) => T} callback The callback to wrap the value
|
|
32
|
+
* @param {...Args} parameters Parameters to pass to the given callback
|
|
33
|
+
* @returns {T extends Promise<infer V> ? Promise<Option<V>> : Option<T>} The result wrapped in an `Option`
|
|
34
|
+
*
|
|
35
|
+
* @see {@link Option} for more details about an option value
|
|
36
|
+
* @see {@link unwrap} for a utility that handles option values
|
|
37
|
+
*/
|
|
38
|
+
export declare function safe<const T extends never, const Args extends unknown[] = never[]>(callback: (...args: Args) => T, ...parameters: Args): Option<never>;
|
|
39
|
+
export declare function safe<const T extends Promisable<unknown>, const Args extends unknown[] = never[]>(callback: (...args: Args) => T, ...parameters: Args): T extends Promise<infer V> ? Promise<Option<V>> : Option<T>;
|
|
40
|
+
/**
|
|
41
|
+
* Directly returns the option's value, or throws the option's error.
|
|
42
|
+
* An option's error won't be thrown when a fallback is provided.
|
|
43
|
+
*
|
|
44
|
+
* The time complexity for this is `O(1)`.
|
|
45
|
+
*
|
|
46
|
+
* @template {Promisable<?>} T
|
|
47
|
+
* @param {...[option: Option<T>, fallback?: F]} args The callback to wrap the value
|
|
48
|
+
* @returns {T extends Promise<infer V> ? Promise<Option<V>> : Option<T>} The result wrapped in an `Option`
|
|
49
|
+
* @throws If the option is not a success and no `fallback` was provided
|
|
50
|
+
*
|
|
51
|
+
* @see {@link Option} for more details about an option value
|
|
52
|
+
*/
|
|
53
|
+
export declare function unwrap<const T>(...args: [option: Option<T>]): T;
|
|
54
|
+
export declare function unwrap<const T, const F>(...args: [option: Option<T>, fallback: F]): T | F;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Throws the given value.
|
|
3
|
+
*
|
|
4
|
+
* If the given value is a string, it throws the value wrapped in an `Error`.
|
|
5
|
+
* If the given value is a function, it calls the function without argument and throws its result.
|
|
6
|
+
*
|
|
7
|
+
* The time complexity for this is `O(1)`.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* raise("Something went wrong");
|
|
11
|
+
* raise(() => new RangeError("Out of range"));
|
|
12
|
+
* raise(RangeError, "Out of range");
|
|
13
|
+
*
|
|
14
|
+
* @param {?} value The value to throw, a function that produces it, or an error class to construct
|
|
15
|
+
* @returns {never} Never returns, it always throws
|
|
16
|
+
* @throws {Error} If the given `value` is a string
|
|
17
|
+
* @throws {?} The given value
|
|
18
|
+
*/
|
|
19
|
+
export declare function raise(value: unknown): never;
|
|
@@ -1,30 +1,237 @@
|
|
|
1
|
-
import { UtilError } from
|
|
2
|
-
import { Computable } from
|
|
1
|
+
import { UtilError } from "~/error";
|
|
2
|
+
import { type Computable } from "~/misc/utils/compute";
|
|
3
3
|
export declare class RangeUtilError extends UtilError {
|
|
4
4
|
readonly util = "range";
|
|
5
5
|
}
|
|
6
|
+
export type RangeString = ".." | `${number}${">" | ""}..` | `${number}${">" | ""}..${"=" | ""}${number}` | `..${"=" | ""}${number}`;
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {Object} RangeDetails
|
|
9
|
+
* @template T
|
|
10
|
+
* @prop {number | null} [start] A number to define the start of the Range
|
|
11
|
+
* @prop {boolean} [inclusiveStart=true] Wether or not the start value is inclusive
|
|
12
|
+
* @prop {number | null} [end] A number to define the end of the Range
|
|
13
|
+
* @prop {boolean} [inclusiveEnd=false] Wether or not the end value is inclusive
|
|
14
|
+
* @prop {number | null} [step] A number to define the step of the Range
|
|
15
|
+
* @prop {Computable<T, [step: number]>} [mapper] A mapper to map the current step of the range to a given value that will be returned by the Range
|
|
16
|
+
*/
|
|
17
|
+
export interface RangeDetails<T> {
|
|
18
|
+
/**
|
|
19
|
+
* A number to define the start of the Range.
|
|
20
|
+
*/
|
|
21
|
+
start?: number | null;
|
|
22
|
+
/**
|
|
23
|
+
* Wether or not the start value is inclusive.
|
|
24
|
+
*
|
|
25
|
+
* @default true
|
|
26
|
+
*/
|
|
27
|
+
inclusiveStart?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* A number to define the end of the Range.
|
|
30
|
+
*/
|
|
31
|
+
end?: number | null;
|
|
32
|
+
/**
|
|
33
|
+
* Wether or not the end value is inclusive.
|
|
34
|
+
*
|
|
35
|
+
* @default false
|
|
36
|
+
*/
|
|
37
|
+
inclusiveEnd?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* A number to define the step of the Range.
|
|
40
|
+
*/
|
|
41
|
+
step?: number | null;
|
|
42
|
+
/**
|
|
43
|
+
* A mapper to map the current step of the range to a given value that will be returned by the Range.
|
|
44
|
+
*/
|
|
45
|
+
mapper?: Computable<T, [step: number]> | undefined;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* @typedef {Object} InternalRangeDetails
|
|
49
|
+
* @template T
|
|
50
|
+
* @prop {number | null} [start] The current start value of the range
|
|
51
|
+
* @prop {boolean} inclusiveStart The current inclusivity of the start value of the Range
|
|
52
|
+
* @prop {number | null} [end] The current end value of the range
|
|
53
|
+
* @prop {boolean} inclusiveEnd The current inclusivity of the end value of the Range
|
|
54
|
+
* @prop {number | null} [step] The current step value of the range
|
|
55
|
+
* @prop {Computable<T, [step: number]>} [mapper] The current mapper of the range
|
|
56
|
+
*/
|
|
57
|
+
export interface InternalRangeDetails<T> {
|
|
58
|
+
/**
|
|
59
|
+
* The current start value of the range.
|
|
60
|
+
*
|
|
61
|
+
* @returns {number | undefined} The start value.
|
|
62
|
+
*/
|
|
63
|
+
get start(): number | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* If the given range should consider the start value to be inclusive.
|
|
66
|
+
*
|
|
67
|
+
* @returns {boolean} If the start value is inclusive.
|
|
68
|
+
*/
|
|
69
|
+
get inclusiveStart(): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* The current end value of the range.
|
|
72
|
+
*
|
|
73
|
+
* @returns {number | undefined} The end value.
|
|
74
|
+
*/
|
|
75
|
+
get end(): number | undefined;
|
|
76
|
+
/**
|
|
77
|
+
* If the given range should consider the end value to be inclusive.
|
|
78
|
+
*
|
|
79
|
+
* @returns {boolean} If the end value is inclusive.
|
|
80
|
+
*/
|
|
81
|
+
get inclusiveEnd(): boolean;
|
|
82
|
+
/**
|
|
83
|
+
* The current step value of the range.
|
|
84
|
+
*
|
|
85
|
+
* @returns {number | undefined} The step value.
|
|
86
|
+
*/
|
|
87
|
+
get step(): number | undefined;
|
|
88
|
+
/**
|
|
89
|
+
* The current mapper of the range.
|
|
90
|
+
*
|
|
91
|
+
* @returns {Computable<T, [step: number]> | undefined} The mapper.
|
|
92
|
+
*/
|
|
93
|
+
get mapper(): Computable<T, [step: number]> | undefined;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* A class to hold details about a given range.
|
|
97
|
+
*
|
|
98
|
+
* @template [T=number]
|
|
99
|
+
*/
|
|
100
|
+
export declare class Range<const T = number> {
|
|
101
|
+
#private;
|
|
102
|
+
/**
|
|
103
|
+
* Creates a new Range based on the details of another Range.
|
|
104
|
+
*
|
|
105
|
+
* @template T
|
|
106
|
+
* @param {Range<T>} range A given Range to construct the new Range from
|
|
107
|
+
* @returns {Range<T>} A new Range with the same details as the given Range.
|
|
108
|
+
*/
|
|
109
|
+
static from<const T>(range: Range<T>): Range<T>;
|
|
110
|
+
constructor(details?: RangeString);
|
|
111
|
+
constructor(details: RangeDetails<T>);
|
|
112
|
+
constructor(details: RangeDetails<T> | RangeString);
|
|
113
|
+
/**
|
|
114
|
+
* A getter to be able to read the values of the Range.
|
|
115
|
+
*
|
|
116
|
+
* @returns {InternalRangeDetails<T>} The internal details of the range
|
|
117
|
+
*/
|
|
118
|
+
get details(): InternalRangeDetails<T>;
|
|
119
|
+
/**
|
|
120
|
+
* Creates a new Range with the a new start value specified.
|
|
121
|
+
*
|
|
122
|
+
* @param {number | null} [start] The start value for the new Range.
|
|
123
|
+
* @returns {Range<T>} A new Range with the specified start value set.
|
|
124
|
+
*/
|
|
125
|
+
start(start?: number | null, inclusiveStart?: boolean): Range<T>;
|
|
126
|
+
/**
|
|
127
|
+
* Creates a new Range with the new inclusivity of the start value specified.
|
|
128
|
+
*
|
|
129
|
+
* @param {boolean} inclusiveStart Wether or no the start value should be considered inclusive.
|
|
130
|
+
* @returns {Range<T>} A new Range with the specified inclusivity of the start value set.
|
|
131
|
+
*/
|
|
132
|
+
inclusiveStart(inclusiveStart: boolean): Range<T>;
|
|
133
|
+
/**
|
|
134
|
+
* Creates a new Range with the a new end value specified.
|
|
135
|
+
*
|
|
136
|
+
* @param {number | null} [end] The end value for the new Range.
|
|
137
|
+
* @param {boolean} [inclusiveEnd=this.#inclusiveEnd] Wether or not the end value should be considered inclusive (defaults to current inclusiveEnd value).
|
|
138
|
+
* @returns {Range<T>} A new Range with the specified end value set.
|
|
139
|
+
*/
|
|
140
|
+
end(end?: number | null, inclusiveEnd?: boolean): Range<T>;
|
|
141
|
+
/**
|
|
142
|
+
* Creates a new Range with the new inclusivity of the end value specified.
|
|
143
|
+
*
|
|
144
|
+
* @param {boolean} inclusiveEnd Wether or no the end value should be considered inclusive.
|
|
145
|
+
* @returns {Range<T>} A new Range with the specified inclusivity of the end value set.
|
|
146
|
+
*/
|
|
147
|
+
inclusiveEnd(inclusiveEnd: boolean): Range<T>;
|
|
148
|
+
/**
|
|
149
|
+
* Creates a new Range with the a new step value specified.
|
|
150
|
+
*
|
|
151
|
+
* @param {number | null} [step] The step value for the new Range.
|
|
152
|
+
* @returns {Range<T>} A new Range with the specified step value set.
|
|
153
|
+
*/
|
|
154
|
+
step(step?: number | null): Range<T>;
|
|
155
|
+
/**
|
|
156
|
+
* Creates a new Range with the a new mapper specified.
|
|
157
|
+
*
|
|
158
|
+
* @template [M=number]
|
|
159
|
+
* @param {Computable<M, [step: number]> | undefined} mapper The mapper for the new Range.
|
|
160
|
+
* @returns {Range<M>} A new Range with the specified mapper set.
|
|
161
|
+
*/
|
|
162
|
+
map<const M = number>(mapper: Computable<M, [step: number]> | undefined): Range<M>;
|
|
163
|
+
/**
|
|
164
|
+
* Returns a boolean to signal if the given value is included in the range.
|
|
165
|
+
*
|
|
166
|
+
* Notes:
|
|
167
|
+
* - If the range is a full range, then this will **always** return true.
|
|
168
|
+
* - `NaN` will **always** return false (unless the range is a full range).
|
|
169
|
+
*
|
|
170
|
+
* @param {number} value The value to check.
|
|
171
|
+
* @returns {boolean} A boolean to signal if the specified value is included in the range.
|
|
172
|
+
*/
|
|
173
|
+
includes(value: number): boolean;
|
|
174
|
+
/**
|
|
175
|
+
* Returns a boolean to signal if the given value is excluded from the range.
|
|
176
|
+
*
|
|
177
|
+
* Notes:
|
|
178
|
+
* - If the range is a full range, then this will **always** return false.
|
|
179
|
+
* - `NaN` will **always** return false.
|
|
180
|
+
*
|
|
181
|
+
* @param {number} value The value to check.
|
|
182
|
+
* @returns {boolean} A boolean to signal if the specified value is excluded from the range.
|
|
183
|
+
*/
|
|
184
|
+
excludes(value: number): boolean;
|
|
185
|
+
[Symbol.iterator](): Generator<T>;
|
|
186
|
+
/**
|
|
187
|
+
* Returns an array based on the values of the Range.
|
|
188
|
+
*
|
|
189
|
+
* @returns {T[]} An array based on the values of the Range.
|
|
190
|
+
*/
|
|
191
|
+
toArray(): T[];
|
|
192
|
+
/**
|
|
193
|
+
* Returns a new Range with same details.
|
|
194
|
+
*
|
|
195
|
+
* @returns {Range<T>} A new Range with same details
|
|
196
|
+
*/
|
|
197
|
+
clone(): Range<T>;
|
|
198
|
+
}
|
|
6
199
|
/**
|
|
7
200
|
* @typedef {Object} RangeOptions
|
|
8
201
|
* @template T
|
|
9
|
-
* @prop {T
|
|
10
|
-
* @prop {number} [step] A number to define the steps that should be used by the
|
|
202
|
+
* @prop {Computable<T, [step: number]>} [valueMapper] A mapper to map the current step of the range to a given value that will be returned by the Range
|
|
203
|
+
* @prop {number} [step] A number to define the steps that should be used by the Range
|
|
11
204
|
*/
|
|
12
205
|
export interface RangeOptions<T> {
|
|
13
206
|
/**
|
|
14
|
-
* A mapper to map the current step of the range to a given value that will be returned by the
|
|
207
|
+
* A mapper to map the current step of the range to a given value that will be returned by the Range.
|
|
15
208
|
*
|
|
16
209
|
* @default undefined
|
|
17
210
|
*/
|
|
18
211
|
valueMapper?: Computable<T, [step: number]> | undefined;
|
|
19
212
|
/**
|
|
20
|
-
* A number to define the steps that should be used by the
|
|
213
|
+
* A number to define the steps that should be used by the Range.
|
|
21
214
|
*
|
|
22
215
|
* @default 1
|
|
23
216
|
*/
|
|
24
217
|
step?: number;
|
|
218
|
+
/**
|
|
219
|
+
* wether the start value is considered inclusive.
|
|
220
|
+
*
|
|
221
|
+
* @default true
|
|
222
|
+
*/
|
|
223
|
+
inclusiveStart?: boolean;
|
|
224
|
+
/**
|
|
225
|
+
* wether the end value is considered inclusive.
|
|
226
|
+
*
|
|
227
|
+
* @default true
|
|
228
|
+
*/
|
|
229
|
+
inclusiveEnd?: boolean;
|
|
25
230
|
}
|
|
231
|
+
export declare function range(strings: TemplateStringsArray, ...values: (string | number)[]): Range<number>;
|
|
232
|
+
export declare function range<const T = number>(range: RangeString, options?: RangeOptions<T>): Range<T>;
|
|
26
233
|
/**
|
|
27
|
-
* Returns a
|
|
234
|
+
* Returns a Range that returns values from a specified range.
|
|
28
235
|
*
|
|
29
236
|
* If `start` is greater than `end`, the range will traverse negatively (counting down) instead of positively.
|
|
30
237
|
*
|
|
@@ -79,11 +286,11 @@ export interface RangeOptions<T> {
|
|
|
79
286
|
* }
|
|
80
287
|
*
|
|
81
288
|
* @template [T=number]
|
|
82
|
-
* @param {number} startOrLength The start of the range, or if this is the only parameter given, the length of the range (inclusive)
|
|
83
|
-
* @param {number | undefined} [end] The end of the range (inclusive), if this value is not given, the `startOrLength` will be used to determine the end
|
|
289
|
+
* @param {number | null | undefined} startOrLength The start of the range, or if this is the only parameter given, the length of the range (inclusive)
|
|
290
|
+
* @param {number | null | undefined} [end] The end of the range (inclusive), if this value is not given (undefined), the `startOrLength` will be used to determine the end
|
|
84
291
|
* @param {RangeOptions<T>} [options] The options used to generate the range (see {@link RangeOptions} for more details)
|
|
85
|
-
* @returns {
|
|
292
|
+
* @returns {Range<T>} A Range of a specified range (optionally mapped to a specified value)
|
|
86
293
|
* @throws {RangeUtilError} If `options.step` is `0`
|
|
87
294
|
* @throws {RangeUtilError} If `options.step` is positive while the range traverses negatively (`start` > `end`), or negative while the range traverses positively
|
|
88
295
|
*/
|
|
89
|
-
export declare function range<const T = number>(startOrLength
|
|
296
|
+
export declare function range<const T = number>(startOrLength?: number | null, end?: number | null, options?: RangeOptions<T>): Range<T>;
|