@creejs/commons-lang 2.1.33 → 2.1.34

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.
@@ -1,2 +1,2 @@
1
- !function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((t="undefined"!=typeof globalThis?globalThis:t||self).CommonsLang={})}(this,function(t){"use strict";const r={NOT_FOUND:404,NOT_SUPPORTED:505,NOT_IMPL:501};class e extends Error{static get Code(){return r}static isErrorLike(t){return null!=t&&("_"===t._type&&"number"==typeof t.code)}static timeout(t,r){return new e(`Timeout ${r}ms: ${t}`,504)}static preconditionFailed(t){return new e(`Not Matched: ${t}`,412)}static notFound(t){return new e(`Not Found: ${t}`,404)}static notImpled(){return new e("Not Impled Yet",501)}static notSupported(t){return new e("Not Supported:"+t,505)}static isNotSupported(t){return 505===t?.code}constructor(t,r){super(t),this._type="_",this.code=r}}class n extends Error{static isAggregatedErrorLike(t){return t&&Array.isArray(t.errors)}static isAggregatedError(t){return t instanceof n}constructor(t,r){super(t),this.errors=r??[]}addError(t){this.errors.push(t)}removeError(t){const r=this.errors.indexOf(t);return-1!==r&&(this.errors.splice(r,1),!0)}}var o={get:function(t,r,e){if(null==t)return e;if("string"!=typeof r)throw new Error('"path" must be a string');const n=r.split(".");let o=t;for(const t of n){if(void 0===o[t])return e;o=o[t]}return o},constructorName:i,defaults:function(t,...r){if(null==t)throw new TypeError('"target" Should Not Nil');for(const e of r)if(null!=e)for(const r in e)void 0===t[r]&&(t[r]=e[r]);return t},extend:s,extends:s,equals:function(t,r){if(t===r)return!0;if("function"==typeof t?.equals)return t.equals(r);if("function"==typeof r?.equals)return r.equals(t);return!1},isBrowser:u,isNode:function(){return!u()},cloneToPlainObject:function(t){if(null==t)return t;if("object"!=typeof t)throw new Error("Only Object allowed to clone");return{...t}},deepCloneToPlainObject:function(t){if(null==t)return t;if("object"!=typeof t)throw new Error("Only Object allowed to clone");return JSON.parse(JSON.stringify(t))}};function i(t){return t?.constructor?.name}function s(t,...r){if(null==t)throw new TypeError('"target" must not be null or undefined');for(const e of r)if(null!=e)for(const r in e)t[r]=e[r];return t}function u(){return"undefined"!=typeof window&&"undefined"!=typeof document}var f={isArray:a,isBoolean:c,isBuffer:function(t){return null!=t&&Buffer.isBuffer(t)},isFunction:l,isInstance:y,isIterable:p,isDate:function(t){return null!=t&&t instanceof Date},isError:function(t){return null!=t&&t instanceof Error},isMap:function(t){return null!=t&&"object"==typeof t&&t.constructor===Map},isWeakMap:function(t){return null!=t&&"object"==typeof t&&t.constructor===WeakMap},isNumber:A,isPositive:g,isNegative:w,isNotNegative:d,isNil:h,isNullOrUndefined:function(t){return null==t},isNull:m,isUndefined:b,isPlainObject:N,isObject:E,isPromise:$,isRegExp:function(t){return null!=t&&"object"==typeof t&&t.constructor===RegExp},isSet:function(t){return null!=t&&"object"==typeof t&&t.constructor===Set},isWeakSet:function(t){return null!=t&&"object"==typeof t&&t.constructor===WeakSet},isStream:function(t){return null!=t&&"function"==typeof t.pipe},isString:v,isSymbol:O,isPrimitive:function(t){return null!==t&&("string"==typeof t||"number"==typeof t||"boolean"==typeof t)},isInt8Array:U,isUint8Array:j,isUint8ClampedArray:S,isInt16Array:x,isUint16Array:T,isInt32Array:I,isUint32Array:B,isFloat32Array:k,isFloat64Array:L,isBigInt64Array:F,isBigUint64Array:C,isTypedArray:P,isArrayBuffer:M};function a(t){return Array.isArray(t)}function c(t){return"boolean"==typeof t}function l(t){return"function"==typeof t}function y(t){return null!=t&&"object"==typeof t&&!N(t)}function p(t){return null!=t&&"function"==typeof t[Symbol.iterator]}function h(t){return null==t}function g(t){return!!A(t)&&t>0}function d(t){return!!A(t)&&t>=0}function w(t){return!!A(t)&&t<0}function m(t){return null===t}function b(t){return void 0===t}function A(t){return null!=t&&"number"==typeof t}function E(t){return null!=t&&"object"==typeof t}function N(t){return null!==t&&"object"==typeof t&&(t.constructor===Object||void 0===t.constructor)}function $(t){return null!=t&&"function"==typeof t.then}function v(t){return null!=t&&"string"==typeof t}function O(t){return null!=t&&"symbol"==typeof t}function P(t){return ArrayBuffer.isView(t)&&t.constructor!==DataView}function U(t){return t instanceof Int8Array}function j(t){return t instanceof Uint8Array}function S(t){return t instanceof Uint8ClampedArray}function x(t){return t instanceof Int16Array}function T(t){return t instanceof Uint16Array}function I(t){return t instanceof Int32Array}function B(t){return t instanceof Uint32Array}function k(t){return t instanceof Float32Array}function L(t){return t instanceof Float64Array}function F(t){return t instanceof BigInt64Array}function C(t){return t instanceof BigUint64Array}function M(t){return t instanceof ArrayBuffer}var D={assertNumber:R,assertPositive:J,assertNegative:function(t,r){if(!w(t))throw new Error(`${r?'"'+r+'" ':""}Not Negative: ${t}`)},assertNotNegative:W,assertBoolean:function(t,r){if(!c(t))throw new Error(`${r?'"'+r+'" ':""}Not Boolean: type=${typeof t} value=${rt(t)}`)},assertObject:z,assertPlainObject:function(t,r){if(!N(t))throw new Error(`${r?'"'+r+'" ':""}Not PlainObject: type=${typeof t} value=${rt(t)}`)},assertSymbol:function(t,r){if(!O(t))throw new Error(`${r?'"'+r+'" ':""}Not Symbol: type=${typeof t} value=${rt(t)}`)},assertFunction:H,assertInstance:function(t,r){if(!y(t))throw new Error(`${r?'"'+r+'" ':""}Not Class Instance: type=${typeof t} value=${rt(t)}`)},assertPromise:V,assertNil:function(t,r){if(!h(t))throw new Error(`${r?'"'+r+'" ':""}Neither Null nor Undefined: type=${typeof t} value=${rt(t)}`)},assertNotNil:G,assertNull:function(t,r){if(!m(t))throw new Error(`${r?'"'+r+'" ':""}Not Null: type=${typeof t} value=${rt(t)}`)},assertNotNull:function(t,r){if(m(t))throw new Error((r?'"'+r+'" ':"")+"Should Not Null")},assertUndefined:function(t,r){if(!b(t))throw new Error(`${r?'"'+r+'" ':""}Not Undefined: type=${typeof t} value=${rt(t)}`)},assertString:q,assertArray:_,assertStringOrSymbol:function(t,r){if(!v(t)&&!O(t))throw new Error(`${r?'"'+r+'" ':""}Not String or Symbol: type=${typeof t} value=${rt(t)}`)},assertInt8Array:function(t,r){if(U(t))throw new Error((r?'"'+r+'" ':"")+"Not Int8Array")},assertUint8Array:function(t,r){if(j(t))throw new Error((r?'"'+r+'" ':"")+"Not Uint8Array")},assertUint8ClampedArray:function(t,r){if(S(t))throw new Error((r?'"'+r+'" ':"")+"Not Uint8ClampedArray")},assertInt16Array:function(t,r){if(x(t))throw new Error((r?'"'+r+'" ':"")+"Not Int16Array")},assertUint16Array:function(t,r){if(T(t))throw new Error((r?'"'+r+'" ':"")+"Not Uint16Array")},assertInt32Array:function(t,r){if(I(t))throw new Error((r?'"'+r+'" ':"")+"Not Int32Array")},assertUint32Array:function(t,r){if(B(t))throw new Error((r?'"'+r+'" ':"")+"Not Uint32Array")},assertFloat32Array:function(t,r){if(k(t))throw new Error((r?'"'+r+'" ':"")+"Not Float32Array")},assertFloat64Array:function(t,r){if(L(t))throw new Error((r?'"'+r+'" ':"")+"Not Float64Array")},assertBigInt64Array:function(t,r){if(F(t))throw new Error((r?'"'+r+'" ':"")+"Not BigInt64Array")},assertBigUint64Array:function(t,r){if(C(t))throw new Error((r?'"'+r+'" ':"")+"Not BigUint64Array")},assertTypedArray:function(t,r){if(P(t))throw new Error((r?'"'+r+'" ':"")+"Not TypedArray")},assertArrayBuffer:K,assertIterable:function(t,r){if(!p(t))throw new Error((r?'"'+r+'" ':"")+"Not Iterable")}};function _(t,r){if(!Array.isArray(t))throw new Error(`${r?'"'+r+'" ':""}Not Array: type=${typeof t} value=${rt(t)}`)}function q(t,r){if(!v(t))throw new Error(`${r?'"'+r+'" ':""}Not String: type=${typeof t} value=${rt(t)}`)}function R(t,r){if(!A(t))throw new Error(`${r?'"'+r+'" ':""}Not Number: type=${typeof t} value=${rt(t)}`)}function J(t,r){if(!g(t))throw new Error(`${r?'"'+r+'" ':""}Not Positive: ${t}`)}function W(t,r){if(!d(t))throw new Error(`${r?'"'+r+'" ':""}Not "0 or Positive": ${t}`)}function z(t,r){if(!E(t))throw new Error(`${r?'"'+r+'" ':""}Not Object: type=${typeof t} value=${rt(t)}`)}function H(t,r){if(!l(t))throw new Error(`${r?'"'+r+'" ':""}Not Function: type=${typeof t} value=${rt(t)}`)}function V(t,r){if(!$(t))throw new Error(`${r?'"'+r+'" ':""}Not Promise: type=${typeof t} value=${rt(t)}`)}function G(t,r){if(h(t))throw new Error((r?'"'+r+'" ':"")+"Should Not Nil")}function K(t,r){if(!M(t))throw new Error((r?'"'+r+'" ':"")+"Not ArrayBuffer")}var Y={isEmpty:Q,assertNotEmpty:X,isBlank:Z,assertNotBlank:function(t,r){if(Z(t))throw new Error(`${r?'"'+r+'" ':""}Is Blank: ${t}`)},capitalize:function(t){if(q(t),0===t.length)return t;const r=t.charAt(0),e=r.toUpperCase();return r===e?t:e+t.slice(1)},decapitalize:function(t){if(q(t),0===t.length)return t;const r=t.charAt(0),e=r.toLowerCase();return r===e?t:e+t.slice(1)},splitWithFixedLength:function(t,r,e=" "){if(q(t),R(r),q(e),0===t.length)return[];if(r<=0)throw new Error("length muse >=0");if(t.length<r)return[t.padEnd(r,e)];const n=[];for(let o=0;o<t.length;o+=r){const i=t.substring(o,o+r);n.push(i.padEnd(r,e))}return n},split:function(t,...r){q(t);if(0===t.length)return[];const e=[...r];0===r.length&&r.push(",");const n=tt(t,...e);if(0===n.length)return[];const o=[];let i="",s=0;for(const{marker:r,index:e}of n)i=t.substring(s,e),o.push(i),s=e+r.length;return i=t.substring(s),o.push(i),o},findMarkerPositions:function(t,...r){if(q(t),0===r.length)throw new Error("At least one marker must be provided");const e=[];for(const n of new Set(r)){if(Q(n))continue;q(n);let r=t.indexOf(n);for(;-1!==r;)e.push({marker:n,index:r}),r=t.indexOf(n,r+n.length)}return e.sort((t,r)=>t.index-r.index),e},findMarkerPositionsRegex:tt,substringBefore:function(t,r){if(q(t),q(r),0===t.length||0===r.length)return;const e=t.indexOf(r);if(-1===e)return;return t.substring(0,e)},substringBeforeLast:function(t,r){if(q(t),q(r),0===t.length||0===r.length)return;const e=t.lastIndexOf(r);if(-1===e)return;return t.substring(0,e)},substringAfter:function(t,r){if(q(t),q(r),0===t.length||0===r.length)return;const e=t.indexOf(r);if(-1===e)return;return t.substring(e+r.length)},substringAfterLast:function(t,r){if(q(t),q(r),0===t.length||0===r.length)return;const e=t.lastIndexOf(r);if(-1===e)return;return t.substring(e+r.length)},substringBetween:function(t,r,e){X(t),X(r),X(e);const n=t.indexOf(r);if(-1===n)return;const o=t.indexOf(e,n+r.length);if(-1===o)return;return t.substring(n+r.length,o)},substringBetweenGreedy:function(t,r,e){X(t),X(r),X(e);const n=t.indexOf(r);if(-1===n)return;const o=t.lastIndexOf(e);if(-1===o||o<=n)return;return t.substring(n+r.length,o)},substringsBetween:function(t,r,e){X(t),X(r),X(e);const n=[];let o=0;for(;;){const i=t.indexOf(r,o);if(-1===i)break;const s=t.indexOf(e,i+r.length);if(-1===s)break;n.push(t.substring(i+r.length,s)),o=s+e.length}return n},safeToString:rt};function Q(t){return null==t||(q(t),0===t.length)}function X(t,r){if(Q(t))throw new Error(`${r?'"'+r+'" ':""}IsEmpty String: ${t}`)}function Z(t){return null==t||(q(t),0===t.trim().length)}function tt(t,...r){if(q(t),0===r.length)throw new Error("At least one marker must be provided");const e=[...new Set(r.filter(t=>null!=t))].map(t=>(q(t),t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"))),n=new RegExp(e.map(t=>`(${t})`).join("|"),"g"),o=[];let i=null;for(;null!==(i=n.exec(t));){for(let t=1;t<i.length;t++)if(i[t]){o.push({marker:r[t-1],index:i.index});break}0===i[0].length&&n.lastIndex++}return o}function rt(t){if(null===t)return"null";if(void 0===t)return"undefined";const r=typeof t;if("string"===r)return t;if("symbol"===r)return`Symbol(${t.description})`;if("function"===r)return`Function ${t.name}(){}`;if(t instanceof String)return t.toString();if(Number.isNaN(t))return"NaN";if(t===1/0)return"Infinity";if(t===-1/0)return"-Infinity";if(t instanceof Error)return`${t.constructor.name}: ${t.message}`;if(t instanceof Promise)return"Promise";if(t instanceof Set)return`Set: ${rt(Array.from(t))}`;if(t instanceof Map)return`Map: ${rt(Array.from(t.entries()))}`;if(t instanceof RegExp)return t.toString();if(Array.isArray(t))return`[${t.map(rt).join(", ")}]`;let e;try{e=JSON.stringify(t)}catch(r){e=t.toString()}return e}var et={quiet:function(t,r){H(t);try{const e=t();return $(e)?e.catch(t=>{r&&r.isErrorEnabled()&&r.error("quiet() with async error:",t)}):e}catch(t){r&&r.isErrorEnabled()&&r.error("quiet() with sync error:",t)}},quietKeepError:function(t,r){H(t),_(r);try{const e=t();return $(e)?e.catch(t=>r.push(t)):e}catch(t){r.push(t)}}},nt={any:function(t){if(_(t),0===t.length)throw new Error("Empty Tasks");const r=ot(),e=[];for(let o=0;o<t.length;o++){const i=t[o];let s;if(f.isPromise(i))s=i;else{if(!f.isFunction(i)){e.push(new Error(`Invalid Task at index ${o}/${t.length-1}: ${i}`));continue}s=st(i)}s.then(t=>{r.resolve(t)}).catch(o=>{e.push(o),e.length>=t.length&&r.reject(new n("All Tasks Failed",e))})}e.length===t.length&&r.reject(new n("All Tasks Failed",e));return r.promise},defer:ot,delay:function(t,r){f.isNumber(t)?(r=t,t=Promise.resolve()):null==t&&null==r&&(r=1,t=Promise.resolve());null!=t&&V(t),R(r=r??1e3);const e=ot(),n=Date.now();return t.then((...t)=>{const o=Date.now()-n;o<r?setTimeout(()=>e.resolve(...t),r-o):e.resolve(...t)}).catch(t=>{const o=Date.now()-n;o<r?setTimeout(()=>e.reject(t),r-o):e.reject(t)}),e.promise},timeout:function(t,r,e){V(t),R(r=r??1);const n=ot(r,e),o=Date.now();return t.then((...t)=>{Date.now()-o<=r?n.resolve(...t):n.reject(new Error(e??`Promise Timeout: ${r}ms`))}).catch(t=>{!n.resolved&&!n.rejected&&n.reject(t)}),n.promise},allSettled:it,returnValuePromised:st,series:async function(t){_(t);const r=[];for(const e of t)if(H(e),f.isFunction(e))r.push(await st(e));else{if(!f.isPromise(e))throw new Error(`Invalid Task: ${e}`);r.push(await e)}return r},seriesAllSettled:async function(t){_(t);const r=[];for(const e of t){H(e);try{r.push({ok:!0,result:await e()})}catch(t){r.push({ok:!1,result:t})}}return r},parallel:async function(t,r=5){if(_(t),R(r),r<=0)throw new Error(`Invalid maxParallel: ${r}, should > 0`);t.forEach(t=>H(t));const e=[];if(t.length<=r){const r=await Promise.all(t.map(t=>st(t)));return e.push(...r),e}const n=[];for(const o of t)if(H(o),n.push(o),n.length>=r){const t=await Promise.all(n.map(t=>st(t)));e.push(...t),n.length=0}if(n.length>0&&n.length<r){const t=await Promise.all(n.map(t=>st(t)));e.push(...t)}return e},parallelAny:async function(t,r=5,e){if(_(t,"tasks"),R(r),0===t.length)throw new Error("Empty Tasks");if(r<=0)throw new Error(`Invalid maxParallel: ${r}, should > 0`);const o=[];let i=0,s=0;const u=ot();function a(){if(i>=t.length)return;if(s>r)return;const c=t[i++];let l;s++,l=f.isPromise(c)?c:f.isFunction(c)?st(c):Promise.reject(new TypeError(`Invalid task: ${typeof c}, Only Promise or Function allowed`)),l.then(t=>{s--,u.resolve(t)}).catch(r=>{o.push(r),o.length>=t.length&&u.pending?u.reject(new n(e??"All Tasks Failed",o)):(s--,a())})}const c=Math.min(t.length,r);for(let t=0;t<c;t++)a();return u.promise},parallelAllSettled:async function(t,r=5){if(_(t),R(r),r<=0)throw new Error(`Invalid maxParallel: ${r}, should > 0`);t.forEach(t=>H(t));const e=[];if(t.length<=r){const r=await it(t.map(t=>st(t)));return e.push(...r),e}const n=[];for(const o of t)if(n.push(o),n.length>=r){const t=await it(n.map(t=>st(t)));e.push(...t),n.length=0}if(n.length>0&&n.length<r){const t=await it(n.map(t=>st(t)));e.push(...t)}return e},wait:function(t){W(t);const r={};let e;return r.timerHandler=e=setTimeout(()=>{clearTimeout(e),r._resolve()},t),r.promise=new Promise((t,n)=>{r._resolve=r=>{null!=e&&clearTimeout(e),t(r)}}),r.wakeup=()=>{r._resolve()},r}};function ot(t=-1,r){R(t);const e={};let n;return e.pending=!0,e.canceled=!1,e.rejected=!1,e.resolved=!1,t>=0&&(e.timerCleared=!1,e.timerHandler=n=setTimeout(()=>{clearTimeout(n),e.timerCleared=!0,e.reject(new Error(r??`Promise Timeout: ${t}ms`))},t)),e.promise=new Promise((t,r)=>{e.resolve=r=>{e.resolved||e.rejected||e.canceled||(null!=n&&(clearTimeout(n),e.timerCleared=!0),e.pending=!1,e.canceled=!1,e.rejected=!1,e.resolved=!0,t(r))},e.reject=t=>{e.resolved||e.rejected||e.canceled||(null!=n&&(clearTimeout(n),e.timerCleared=!0),e.pending=!1,e.canceled=!1,e.resolved=!1,e.rejected=!0,r(t))}}),e.cancel=e.promise.cancel=t=>{e.resolved||e.rejected||e.canceled||(null!=n&&(clearTimeout(n),e.timerCleared=!0),e.reject(t??new Error("Cancelled")),e.canceled=e.promise.canceled=!0)},e}async function it(t){_(t);const r=await Promise.allSettled(t),e=[];for(const t of r)"fulfilled"===t.status&&e.push({ok:!0,result:t.value}),"rejected"===t.status&&e.push({ok:!1,result:t.reason});return e}function st(t){try{const r=t();return f.isPromise(r)?r:Promise.resolve(r)}catch(t){return Promise.reject(t)}}const{isPlainObject:ut}=f;var ft={proxy:at,newProxyInstance:function(t,r,e,n=!0){const o=at(t,e,n);return Reflect.construct(o,r??[])}};function at(t,r,e=!0){if("function"!=typeof t)throw new TypeError(`Not Class: type=${typeof t}, value=${JSON.stringify(t)}`);if(null!=r){if(!ut(r))throw new TypeError(`Not PropertyHandler: type=${typeof r}, value=${JSON.stringify(r)}`);const{get:t,set:e}=r;if(null!=t&&"function"!=typeof t)throw new TypeError(`Not PropertyHandler.get: type=${typeof t}, value=${JSON.stringify(t)}`);if(null!=e&&"function"!=typeof e)throw new TypeError(`Not PropertyHandler.set: type=${typeof e}, value=${JSON.stringify(e)}`)}const n={construct(t,n,o){const i=Reflect.construct(t,n);return new Proxy(e?Object.preventExtensions(i):i,r??{})}};return new Proxy(t,n)}var ct={proxy:function(t,r,e=!0){if(h(t)||!E(t)||a(t))throw new TypeError(`Not Object: type=${typeof t}, value=${JSON.stringify(t)}`);return new Proxy(e?Object.preventExtensions(t):t,r??{})}};function lt(t){z(t,"obj");const r=new Set;let e=t;for(;e&&e!==Object.prototype;){const n=Object.getOwnPropertyNames(e);for(const e of n)"constructor"!==e&&"function"==typeof t[e]&&r.add(e);e=Object.getPrototypeOf(e)}return[...new Set(r)]}var yt={getMethodsOfClass:function(t){H(t,"cls");const r=new Set;let e=t.prototype;for(;e&&e!==Object.prototype;){const t=Object.getOwnPropertyNames(e);for(const n of t)"constructor"!==n&&"function"==typeof e[n]&&r.add(n);e=Object.getPrototypeOf(e)}return[...new Set(r)]},getStaticMethodsOfClass:function(t){H(t,"cls");const r=new Set;let e=t;for(;e&&e!==Object.getPrototypeOf(Object);){const t=Object.getOwnPropertyNames(e);for(const n of t)"function"==typeof e[n]&&r.add(n);e=Object.getPrototypeOf(e)}return[...r]},getMethods:lt,getMethodsOfObject:lt},pt={startsWith:function(t,r){G(t,"src"),G(r,"searching");return gt(t.subarray(0,r.length),r)},isSameType:ht,equals:gt};function ht(t,r){return G(t,"src"),G(r,"target"),i(t)===i(r)}function gt(t,r){if(G(t,"src"),G(r,"target"),!ht(t,r))return!1;if(t.byteLength!==r.byteLength)return!1;const e=new DataView(t.buffer,t.byteOffset,t.byteLength),n=new DataView(r.buffer,r.byteOffset,r.byteLength);for(let r=0;r<t.byteLength;r++)if(e.getUint8(r)!==n.getUint8(r))return!1;return!0}var dt={readString:function(t,r=0,e){if(K(t),W(r),r>=t.byteLength)return;let n=null;null!=e?(J(e),n=r+e>=t.byteLength?new Uint8Array(t,r):new Uint8Array(t,r,e)):n=new Uint8Array(t,r);return wt.decode(n)},writeString:function(t,r,e=0){K(t,"buffer"),q(r,"str"),W(e,"offset");const n=mt.encode(r),o=n.byteLength;if(e+o>t.byteLength)throw new Error(`offset + str.byteLength > buffer.byteLength:${e+o} > ${t.byteLength}`);new Uint8Array(t,e,n.byteLength).set(n)},writeArrayBuffer:function(t,r,e=0,n=0,o){K(t),K(r),R(e),R(n);const i=t.byteLength;if(e<-1*i)e=0;else if(e<0)e+=i;else if(e>=i)throw new Error(`Out of target Bounds: targetOffset(${e}) >= targetLength(${i})`);const s=r.byteLength;if(n<-1*s)n=0;else if(n<0)n+=s;else if(n>=s)throw new Error(`Out of data Bounds: dataOffset(${n}) >= dataArrayBufferLength(${s})`);null!=o&&(J(o,"dataLength"),n+o>s&&(o=void 0));const u=new Uint8Array(r,n,o);if(u.byteLength>i-e)throw new Error(`Out of target Bounds: from targetOffset(${e}), No Space to store dataArrayBuffer(${n}, ${o??"NoLimit"})`);new Uint8Array(t).set(u,e)}};const wt=new TextDecoder,mt=new TextEncoder;const bt=1e6;var At={s2ns:1e9,ms2ns:bt,timestamp:function(){if("undefined"!=typeof performance&&"number"==typeof performance.timeOrigin){const t=performance.timeOrigin,r=performance.now();return Math.ceil((t+r)/bt)}return Date.now()},timestamp64:Et,lapseNano:Nt,lapseMillis:$t,timeoutNano:function(t,r){return Nt(t)>r},timeoutMillis:function(t,r){return $t(t)>r}};function Et(){if("undefined"!=typeof performance&&"number"==typeof performance.timeOrigin){const t=performance.timeOrigin,r=performance.now();return BigInt((t+r)*bt)}return BigInt(Date.now()*bt)}function Nt(t,r){return(r??Et())-t}function $t(t,r){r=r??Et();return BigInt(r-t)/BigInt(bt)}var vt={first:function(t,r){return _(t,"arr"),t[0]??r},chunk:function(t,r){if(_(t,"array"),J(r,"size"),t.length<=r)return t;const e=[];let n=0;for(;n<t.length;)e.push(t.slice(n,r+n)),n+=r;return e},last:function(t,r){return _(t,"arr"),t[t.length-1]??r},equals:function(t,r,e){if(!Array.isArray(t)||!Array.isArray(r))return!1;if(t.length!==r.length)return!1;for(let n=0;n<t.length;n++)if(e){if(0!==e(t[n],r[n]))return!1}else if(t[n]!==r[n])return!1;return!0},equalsIgnoreOrder:function(t,r,e){if(!Array.isArray(t)||!Array.isArray(r))return!1;if(t.length!==r.length)return!1;t.sort(e),r.sort(e);for(let n=0;n<t.length;n++)if(e){if(0!==e(t[n],r[n]))return!1}else if(t[n]!==r[n])return!1;return!0}};var Ot={length:function(t){if(D.assertIterable(t),void 0!==t.length)return t.length;if(void 0!==t.size)return t.size;let r=0;for(const e of t)r++;return r}},Pt={_Error:e,AggregatedError:n,LangUtils:o,StringUtils:Y,TypeUtils:f,TypeAssert:D,ExecUtils:et,PromiseUtils:nt,Lang:o,Type:f,Exec:et,ClassProxyUtils:ft,InstanceProxyUtils:ct,ReflectUtils:yt,TypedArrayUtils:pt,ArrayBufferUtils:dt,TimeUtils:At,ArrayUtils:vt,IteratorUtils:Ot};t.AggregatedError=n,t.ArrayBufferUtils=dt,t.ArrayUtils=vt,t.ClassProxyUtils=ft,t.Exec=et,t.ExecUtils=et,t.InstanceProxyUtils=ct,t.IteratorUtils=Ot,t.Lang=o,t.LangUtils=o,t.PromiseUtils=nt,t.ReflectUtils=yt,t.StringUtils=Y,t.TimeUtils=At,t.Type=f,t.TypeAssert=D,t.TypeUtils=f,t.TypedArrayUtils=pt,t._Error=e,t.default=Pt,Object.defineProperty(t,"__esModule",{value:!0})});
1
+ !function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((t="undefined"!=typeof globalThis?globalThis:t||self).CommonsLang={})}(this,function(t){"use strict";const r={NOT_FOUND:404,NOT_SUPPORTED:505,NOT_IMPL:501};class e extends Error{static get Code(){return r}static isErrorLike(t){return null!=t&&("_"===t._type&&"number"==typeof t.code)}static timeout(t,r){return new e(`Timeout ${r}ms: ${t}`,504)}static preconditionFailed(t){return new e(`Not Matched: ${t}`,412)}static notFound(t){return new e(`Not Found: ${t}`,404)}static notImpled(){return new e("Not Impled Yet",501)}static notSupported(t){return new e("Not Supported:"+t,505)}static isNotSupported(t){return 505===t?.code}constructor(t,r){super(t),this._type="_",this.code=r}}class n extends Error{static isAggregatedErrorLike(t){return t&&Array.isArray(t.errors)}static isAggregatedError(t){return t instanceof n}constructor(t,r){super(t),this.errors=r??[]}addError(t){this.errors.push(t)}removeError(t){const r=this.errors.indexOf(t);return-1!==r&&(this.errors.splice(r,1),!0)}}var o={get:function(t,r,e){if(null==t)return e;if("string"!=typeof r)throw new Error('"path" must be a string');const n=r.split(".");let o=t;for(const t of n){if(void 0===o[t])return e;o=o[t]}return o},constructorName:i,defaults:function(t,...r){if(null==t)throw new TypeError('"target" Should Not Nil');for(const e of r)if(null!=e)for(const r in e)void 0===t[r]&&(t[r]=e[r]);return t},extend:s,extends:s,equals:function(t,r){if(t===r)return!0;if("function"==typeof t?.equals)return t.equals(r);if("function"==typeof r?.equals)return r.equals(t);return!1},isBrowser:u,isNode:function(){return!u()},cloneToPlainObject:function(t){if(null==t)return t;if("object"!=typeof t)throw new Error("Only Object allowed to clone");return{...t}},deepCloneToPlainObject:function(t){if(null==t)return t;if("object"!=typeof t)throw new Error("Only Object allowed to clone");return JSON.parse(JSON.stringify(t))}};function i(t){return t?.constructor?.name}function s(t,...r){if(null==t)throw new TypeError('"target" must not be null or undefined');for(const e of r)if(null!=e)for(const r in e)t[r]=e[r];return t}function u(){return"undefined"!=typeof window&&"undefined"!=typeof document}var f={isArray:a,isBoolean:c,isBuffer:function(t){return null!=t&&Buffer.isBuffer(t)},isFunction:l,isInstance:y,isIterable:p,isDate:function(t){return null!=t&&t instanceof Date},isError:function(t){return null!=t&&t instanceof Error},isMap:function(t){return null!=t&&"object"==typeof t&&t.constructor===Map},isWeakMap:function(t){return null!=t&&"object"==typeof t&&t.constructor===WeakMap},isNumber:A,isPositive:g,isNegative:w,isNotNegative:d,isNil:h,isNullOrUndefined:function(t){return null==t},isNull:m,isUndefined:b,isPlainObject:N,isObject:E,isPromise:$,isRegExp:function(t){return null!=t&&"object"==typeof t&&t.constructor===RegExp},isSet:function(t){return null!=t&&"object"==typeof t&&t.constructor===Set},isWeakSet:function(t){return null!=t&&"object"==typeof t&&t.constructor===WeakSet},isStream:function(t){return null!=t&&"function"==typeof t.pipe},isString:O,isSymbol:v,isPrimitive:function(t){return null!==t&&("string"==typeof t||"number"==typeof t||"boolean"==typeof t)},isInt8Array:U,isUint8Array:j,isUint8ClampedArray:S,isInt16Array:x,isUint16Array:T,isInt32Array:I,isUint32Array:B,isFloat32Array:k,isFloat64Array:L,isBigInt64Array:F,isBigUint64Array:C,isTypedArray:P,isArrayBuffer:M};function a(t){return Array.isArray(t)}function c(t){return"boolean"==typeof t}function l(t){return"function"==typeof t}function y(t){return null!=t&&"object"==typeof t&&!N(t)}function p(t){return null!=t&&"function"==typeof t[Symbol.iterator]}function h(t){return null==t}function g(t){return!!A(t)&&t>0}function d(t){return!!A(t)&&t>=0}function w(t){return!!A(t)&&t<0}function m(t){return null===t}function b(t){return void 0===t}function A(t){return null!=t&&"number"==typeof t}function E(t){return null!=t&&"object"==typeof t}function N(t){return null!==t&&"object"==typeof t&&(t.constructor===Object||void 0===t.constructor)}function $(t){return null!=t&&"function"==typeof t.then}function O(t){return null!=t&&"string"==typeof t}function v(t){return null!=t&&"symbol"==typeof t}function P(t){return ArrayBuffer.isView(t)&&t.constructor!==DataView}function U(t){return t instanceof Int8Array}function j(t){return t instanceof Uint8Array}function S(t){return t instanceof Uint8ClampedArray}function x(t){return t instanceof Int16Array}function T(t){return t instanceof Uint16Array}function I(t){return t instanceof Int32Array}function B(t){return t instanceof Uint32Array}function k(t){return t instanceof Float32Array}function L(t){return t instanceof Float64Array}function F(t){return t instanceof BigInt64Array}function C(t){return t instanceof BigUint64Array}function M(t){return t instanceof ArrayBuffer}var D={assertNumber:R,assertPositive:J,assertNegative:function(t,r){if(!w(t))throw new Error(`${r?'"'+r+'" ':""}Not Negative: ${t}`)},assertNotNegative:W,assertBoolean:function(t,r){if(!c(t))throw new Error(`${r?'"'+r+'" ':""}Not Boolean: type=${typeof t} value=${rt(t)}`)},assertObject:H,assertPlainObject:function(t,r){if(!N(t))throw new Error(`${r?'"'+r+'" ':""}Not PlainObject: type=${typeof t} value=${rt(t)}`)},assertSymbol:function(t,r){if(!v(t))throw new Error(`${r?'"'+r+'" ':""}Not Symbol: type=${typeof t} value=${rt(t)}`)},assertFunction:V,assertInstance:function(t,r){if(!y(t))throw new Error(`${r?'"'+r+'" ':""}Not Class Instance: type=${typeof t} value=${rt(t)}`)},assertPromise:z,assertNil:function(t,r){if(!h(t))throw new Error(`${r?'"'+r+'" ':""}Neither Null nor Undefined: type=${typeof t} value=${rt(t)}`)},assertNotNil:G,assertNull:function(t,r){if(!m(t))throw new Error(`${r?'"'+r+'" ':""}Not Null: type=${typeof t} value=${rt(t)}`)},assertNotNull:function(t,r){if(m(t))throw new Error((r?'"'+r+'" ':"")+"Should Not Null")},assertUndefined:function(t,r){if(!b(t))throw new Error(`${r?'"'+r+'" ':""}Not Undefined: type=${typeof t} value=${rt(t)}`)},assertString:q,assertArray:_,assertStringOrSymbol:function(t,r){if(!O(t)&&!v(t))throw new Error(`${r?'"'+r+'" ':""}Not String or Symbol: type=${typeof t} value=${rt(t)}`)},assertInt8Array:function(t,r){if(U(t))throw new Error((r?'"'+r+'" ':"")+"Not Int8Array")},assertUint8Array:function(t,r){if(j(t))throw new Error((r?'"'+r+'" ':"")+"Not Uint8Array")},assertUint8ClampedArray:function(t,r){if(S(t))throw new Error((r?'"'+r+'" ':"")+"Not Uint8ClampedArray")},assertInt16Array:function(t,r){if(x(t))throw new Error((r?'"'+r+'" ':"")+"Not Int16Array")},assertUint16Array:function(t,r){if(T(t))throw new Error((r?'"'+r+'" ':"")+"Not Uint16Array")},assertInt32Array:function(t,r){if(I(t))throw new Error((r?'"'+r+'" ':"")+"Not Int32Array")},assertUint32Array:function(t,r){if(B(t))throw new Error((r?'"'+r+'" ':"")+"Not Uint32Array")},assertFloat32Array:function(t,r){if(k(t))throw new Error((r?'"'+r+'" ':"")+"Not Float32Array")},assertFloat64Array:function(t,r){if(L(t))throw new Error((r?'"'+r+'" ':"")+"Not Float64Array")},assertBigInt64Array:function(t,r){if(F(t))throw new Error((r?'"'+r+'" ':"")+"Not BigInt64Array")},assertBigUint64Array:function(t,r){if(C(t))throw new Error((r?'"'+r+'" ':"")+"Not BigUint64Array")},assertTypedArray:function(t,r){if(P(t))throw new Error((r?'"'+r+'" ':"")+"Not TypedArray")},assertArrayBuffer:K,assertIterable:function(t,r){if(!p(t))throw new Error((r?'"'+r+'" ':"")+"Not Iterable")}};function _(t,r){if(!Array.isArray(t))throw new Error(`${r?'"'+r+'" ':""}Not Array: type=${typeof t} value=${rt(t)}`)}function q(t,r){if(!O(t))throw new Error(`${r?'"'+r+'" ':""}Not String: type=${typeof t} value=${rt(t)}`)}function R(t,r){if(!A(t))throw new Error(`${r?'"'+r+'" ':""}Not Number: type=${typeof t} value=${rt(t)}`)}function J(t,r){if(!g(t))throw new Error(`${r?'"'+r+'" ':""}Not Positive: ${t}`)}function W(t,r){if(!d(t))throw new Error(`${r?'"'+r+'" ':""}Not "0 or Positive": ${t}`)}function H(t,r){if(!E(t))throw new Error(`${r?'"'+r+'" ':""}Not Object: type=${typeof t} value=${rt(t)}`)}function V(t,r){if(!l(t))throw new Error(`${r?'"'+r+'" ':""}Not Function: type=${typeof t} value=${rt(t)}`)}function z(t,r){if(!$(t))throw new Error(`${r?'"'+r+'" ':""}Not Promise: type=${typeof t} value=${rt(t)}`)}function G(t,r){if(h(t))throw new Error((r?'"'+r+'" ':"")+"Should Not Nil")}function K(t,r){if(!M(t))throw new Error((r?'"'+r+'" ':"")+"Not ArrayBuffer")}var Y={isEmpty:Q,assertNotEmpty:X,isBlank:Z,assertNotBlank:function(t,r){if(Z(t))throw new Error(`${r?'"'+r+'" ':""}Is Blank: ${t}`)},capitalize:function(t){if(q(t),0===t.length)return t;const r=t.charAt(0),e=r.toUpperCase();return r===e?t:e+t.slice(1)},decapitalize:function(t){if(q(t),0===t.length)return t;const r=t.charAt(0),e=r.toLowerCase();return r===e?t:e+t.slice(1)},splitWithFixedLength:function(t,r,e=" "){if(q(t),R(r),q(e),0===t.length)return[];if(r<=0)throw new Error("length muse >=0");if(t.length<r)return[t.padEnd(r,e)];const n=[];for(let o=0;o<t.length;o+=r){const i=t.substring(o,o+r);n.push(i.padEnd(r,e))}return n},split:function(t,...r){q(t);if(0===t.length)return[];const e=[...r];0===r.length&&r.push(",");const n=tt(t,...e);if(0===n.length)return[];const o=[];let i="",s=0;for(const{marker:r,index:e}of n)i=t.substring(s,e),o.push(i),s=e+r.length;return i=t.substring(s),o.push(i),o},findMarkerPositions:function(t,...r){if(q(t),0===r.length)throw new Error("At least one marker must be provided");const e=[];for(const n of new Set(r)){if(Q(n))continue;q(n);let r=t.indexOf(n);for(;-1!==r;)e.push({marker:n,index:r}),r=t.indexOf(n,r+n.length)}return e.sort((t,r)=>t.index-r.index),e},findMarkerPositionsRegex:tt,substringBefore:function(t,r){if(q(t),q(r),0===t.length||0===r.length)return;const e=t.indexOf(r);if(-1===e)return;return t.substring(0,e)},substringBeforeLast:function(t,r){if(q(t),q(r),0===t.length||0===r.length)return;const e=t.lastIndexOf(r);if(-1===e)return;return t.substring(0,e)},substringAfter:function(t,r){if(q(t),q(r),0===t.length||0===r.length)return;const e=t.indexOf(r);if(-1===e)return;return t.substring(e+r.length)},substringAfterLast:function(t,r){if(q(t),q(r),0===t.length||0===r.length)return;const e=t.lastIndexOf(r);if(-1===e)return;return t.substring(e+r.length)},substringBetween:function(t,r,e){X(t),X(r),X(e);const n=t.indexOf(r);if(-1===n)return;const o=t.indexOf(e,n+r.length);if(-1===o)return;return t.substring(n+r.length,o)},substringBetweenGreedy:function(t,r,e){X(t),X(r),X(e);const n=t.indexOf(r);if(-1===n)return;const o=t.lastIndexOf(e);if(-1===o||o<=n)return;return t.substring(n+r.length,o)},substringsBetween:function(t,r,e){X(t),X(r),X(e);const n=[];let o=0;for(;;){const i=t.indexOf(r,o);if(-1===i)break;const s=t.indexOf(e,i+r.length);if(-1===s)break;n.push(t.substring(i+r.length,s)),o=s+e.length}return n},safeToString:rt};function Q(t){return null==t||(q(t),0===t.length)}function X(t,r){if(Q(t))throw new Error(`${r?'"'+r+'" ':""}IsEmpty String: ${t}`)}function Z(t){return null==t||(q(t),0===t.trim().length)}function tt(t,...r){if(q(t),0===r.length)throw new Error("At least one marker must be provided");const e=[...new Set(r.filter(t=>null!=t))].map(t=>(q(t),t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"))),n=new RegExp(e.map(t=>`(${t})`).join("|"),"g"),o=[];let i=null;for(;null!==(i=n.exec(t));){for(let t=1;t<i.length;t++)if(i[t]){o.push({marker:r[t-1],index:i.index});break}0===i[0].length&&n.lastIndex++}return o}function rt(t){if(null===t)return"null";if(void 0===t)return"undefined";const r=typeof t;if("string"===r)return t;if("symbol"===r)return`Symbol(${t.description})`;if("function"===r)return`Function ${t.name}(){}`;if(t instanceof String)return t.toString();if(Number.isNaN(t))return"NaN";if(t===1/0)return"Infinity";if(t===-1/0)return"-Infinity";if(t instanceof Error)return`${t.constructor.name}: ${t.message}`;if(t instanceof Promise)return"Promise";if(t instanceof Set)return`Set: ${rt(Array.from(t))}`;if(t instanceof Map)return`Map: ${rt(Array.from(t.entries()))}`;if(t instanceof RegExp)return t.toString();if(Array.isArray(t))return`[${t.map(rt).join(", ")}]`;let e;try{e=JSON.stringify(t)}catch(r){e=t.toString()}return e}var et={quiet:function(t,r){V(t);try{const e=t();return $(e)?e.catch(t=>{r&&r.isErrorEnabled()&&r.error("quiet() with async error:",t)}):e}catch(t){r&&r.isErrorEnabled()&&r.error("quiet() with sync error:",t)}},quietKeepError:function(t,r){V(t),_(r);try{const e=t();return $(e)?e.catch(t=>r.push(t)):e}catch(t){r.push(t)}}},nt={any:function(t){if(_(t),0===t.length)throw new Error("Empty Tasks");const r=ot(),e=[];for(let o=0;o<t.length;o++){const i=t[o];let s;if(f.isPromise(i))s=i;else{if(!f.isFunction(i)){e.push(new Error(`Invalid Task at index ${o}/${t.length-1}: ${i}`));continue}s=st(i)}s.then(t=>{r.resolve(t)}).catch(o=>{e.push(o),e.length>=t.length&&r.reject(new n("All Tasks Failed",e))})}e.length===t.length&&r.reject(new n("All Tasks Failed",e));return r.promise},defer:ot,delay:function(t,r){f.isNumber(t)?(r=t,t=Promise.resolve()):null==t&&null==r&&(r=1,t=Promise.resolve());null!=t&&z(t),R(r=r??1e3);const e=ot(),n=Date.now();return t.then((...t)=>{const o=Date.now()-n;o<r?setTimeout(()=>e.resolve(...t),r-o):e.resolve(...t)}).catch(t=>{const o=Date.now()-n;o<r?setTimeout(()=>e.reject(t),r-o):e.reject(t)}),e.promise},timeout:function(t,r,e){z(t),R(r=r??1);const n=ot(r,e),o=Date.now();return t.then((...t)=>{Date.now()-o<=r?n.resolve(...t):n.reject(new Error(e??`Promise Timeout: ${r}ms`))}).catch(t=>{!n.resolved&&!n.rejected&&n.reject(t)}),n.promise},allSettled:it,returnValuePromised:st,series:async function(t){_(t);const r=[];for(const e of t)if(V(e),f.isFunction(e))r.push(await st(e));else{if(!f.isPromise(e))throw new Error(`Invalid Task: ${e}`);r.push(await e)}return r},seriesAllSettled:async function(t){_(t);const r=[];for(const e of t){V(e);try{r.push({ok:!0,result:await e()})}catch(t){r.push({ok:!1,result:t})}}return r},parallel:async function(t,r=5){if(_(t),R(r),r<=0)throw new Error(`Invalid maxParallel: ${r}, should > 0`);t.forEach(t=>V(t));const e=[];if(t.length<=r){const r=await Promise.all(t.map(t=>st(t)));return e.push(...r),e}const n=[];for(const o of t)if(V(o),n.push(o),n.length>=r){const t=await Promise.all(n.map(t=>st(t)));e.push(...t),n.length=0}if(n.length>0&&n.length<r){const t=await Promise.all(n.map(t=>st(t)));e.push(...t)}return e},parallelAny:async function(t,r=5,e){if(_(t,"tasks"),R(r),0===t.length)throw new Error("Empty Tasks");if(r<=0)throw new Error(`Invalid maxParallel: ${r}, should > 0`);const o=[];let i=0,s=0;const u=ot();function a(){if(i>=t.length)return;if(s>r)return;const c=t[i++];let l;s++,l=f.isPromise(c)?c:f.isFunction(c)?st(c):Promise.reject(new TypeError(`Invalid task: ${typeof c}, Only Promise or Function allowed`)),l.then(t=>{s--,u.resolve(t)}).catch(r=>{o.push(r),o.length>=t.length&&u.pending?u.reject(new n(e??"All Tasks Failed",o)):(s--,a())})}const c=Math.min(t.length,r);for(let t=0;t<c;t++)a();return u.promise},parallelAllSettled:async function(t,r=5){if(_(t),R(r),r<=0)throw new Error(`Invalid maxParallel: ${r}, should > 0`);t.forEach(t=>V(t));const e=[];if(t.length<=r){const r=await it(t.map(t=>st(t)));return e.push(...r),e}const n=[];for(const o of t)if(n.push(o),n.length>=r){const t=await it(n.map(t=>st(t)));e.push(...t),n.length=0}if(n.length>0&&n.length<r){const t=await it(n.map(t=>st(t)));e.push(...t)}return e},wait:function(t){W(t);const r={};let e;return r.timerHandler=e=setTimeout(()=>{clearTimeout(e),r._resolve()},t),r.promise=new Promise((t,n)=>{r._resolve=r=>{null!=e&&clearTimeout(e),t(r)}}),r.wakeup=()=>{r._resolve()},r}};function ot(t=-1,r){R(t);const e={};let n;return e.pending=!0,e.canceled=!1,e.rejected=!1,e.resolved=!1,t>=0&&(e.timerCleared=!1,e.timerHandler=n=setTimeout(()=>{clearTimeout(n),e.timerCleared=!0,e.reject(new Error(r??`Promise Timeout: ${t}ms`))},t)),e.promise=new Promise((t,r)=>{e.resolve=r=>{e.resolved||e.rejected||e.canceled||(null!=n&&(clearTimeout(n),e.timerCleared=!0),e.pending=!1,e.canceled=!1,e.rejected=!1,e.resolved=!0,t(r))},e.reject=t=>{e.resolved||e.rejected||e.canceled||(null!=n&&(clearTimeout(n),e.timerCleared=!0),e.pending=!1,e.canceled=!1,e.resolved=!1,e.rejected=!0,r(t))}}),e.cancel=e.promise.cancel=t=>{e.resolved||e.rejected||e.canceled||(null!=n&&(clearTimeout(n),e.timerCleared=!0),e.reject(t??new Error("Cancelled")),e.canceled=e.promise.canceled=!0)},e}async function it(t){_(t);const r=await Promise.allSettled(t),e=[];for(const t of r)"fulfilled"===t.status&&e.push({ok:!0,result:t.value}),"rejected"===t.status&&e.push({ok:!1,result:t.reason});return e}function st(t){try{const r=t();return f.isPromise(r)?r:Promise.resolve(r)}catch(t){return Promise.reject(t)}}const{isPlainObject:ut}=f;var ft={proxy:at,newProxyInstance:function(t,r,e,n=!0){const o=at(t,e,n);return Reflect.construct(o,r??[])}};function at(t,r,e=!0){if("function"!=typeof t)throw new TypeError(`Not Class: type=${typeof t}, value=${JSON.stringify(t)}`);if(null!=r){if(!ut(r))throw new TypeError(`Not PropertyHandler: type=${typeof r}, value=${JSON.stringify(r)}`);const{get:t,set:e}=r;if(null!=t&&"function"!=typeof t)throw new TypeError(`Not PropertyHandler.get: type=${typeof t}, value=${JSON.stringify(t)}`);if(null!=e&&"function"!=typeof e)throw new TypeError(`Not PropertyHandler.set: type=${typeof e}, value=${JSON.stringify(e)}`)}const n={construct(t,n,o){const i=Reflect.construct(t,n);return new Proxy(e?Object.preventExtensions(i):i,r??{})}};return new Proxy(t,n)}var ct={proxy:function(t,r,e=!0){if(h(t)||!E(t)||a(t))throw new TypeError(`Not Object: type=${typeof t}, value=${JSON.stringify(t)}`);return new Proxy(e?Object.preventExtensions(t):t,r??{})}};function lt(t){H(t,"obj");const r=new Set;let e=t;for(;e&&e!==Object.prototype;){const n=Object.getOwnPropertyNames(e);for(const e of n)"constructor"!==e&&"function"==typeof t[e]&&r.add(e);e=Object.getPrototypeOf(e)}return[...new Set(r)]}var yt={getMethodsOfClass:function(t){V(t,"cls");const r=new Set;let e=t.prototype;for(;e&&e!==Object.prototype;){const t=Object.getOwnPropertyNames(e);for(const n of t)"constructor"!==n&&"function"==typeof e[n]&&r.add(n);e=Object.getPrototypeOf(e)}return[...new Set(r)]},getStaticMethodsOfClass:function(t){V(t,"cls");const r=new Set;let e=t;for(;e&&e!==Object.getPrototypeOf(Object);){const t=Object.getOwnPropertyNames(e);for(const n of t)"function"==typeof e[n]&&r.add(n);e=Object.getPrototypeOf(e)}return[...r]},getMethods:lt,getMethodsOfObject:lt},pt={startsWith:function(t,r){G(t,"src"),G(r,"searching");return gt(t.subarray(0,r.length),r)},isSameType:ht,equals:gt};function ht(t,r){return G(t,"src"),G(r,"target"),i(t)===i(r)}function gt(t,r){if(G(t,"src"),G(r,"target"),!ht(t,r))return!1;if(t.byteLength!==r.byteLength)return!1;const e=new DataView(t.buffer,t.byteOffset,t.byteLength),n=new DataView(r.buffer,r.byteOffset,r.byteLength);for(let r=0;r<t.byteLength;r++)if(e.getUint8(r)!==n.getUint8(r))return!1;return!0}var dt={readString:function(t,r=0,e){if(K(t),W(r),r>=t.byteLength)return;let n=null;null!=e?(J(e),n=r+e>=t.byteLength?new Uint8Array(t,r):new Uint8Array(t,r,e)):n=new Uint8Array(t,r);return wt.decode(n)},writeString:function(t,r,e=0){K(t,"buffer"),q(r,"str"),W(e,"offset");const n=mt.encode(r),o=n.byteLength;if(e+o>t.byteLength)throw new Error(`offset + str.byteLength > buffer.byteLength:${e+o} > ${t.byteLength}`);new Uint8Array(t,e,n.byteLength).set(n)},writeArrayBuffer:function(t,r,e=0,n=0,o){K(t),K(r),R(e),R(n);const i=t.byteLength;if(e<-1*i)e=0;else if(e<0)e+=i;else if(e>=i)throw new Error(`Out of target Bounds: targetOffset(${e}) >= targetLength(${i})`);const s=r.byteLength;if(n<-1*s)n=0;else if(n<0)n+=s;else if(n>=s)throw new Error(`Out of data Bounds: dataOffset(${n}) >= dataArrayBufferLength(${s})`);null!=o&&(J(o,"dataLength"),n+o>s&&(o=void 0));const u=new Uint8Array(r,n,o);if(u.byteLength>i-e)throw new Error(`Out of target Bounds: from targetOffset(${e}), No Space to store dataArrayBuffer(${n}, ${o??"NoLimit"})`);new Uint8Array(t).set(u,e)}};const wt=new TextDecoder,mt=new TextEncoder;const bt=1e6;var At={s2ns:1e9,ms2ns:bt,timestamp:function(){if("undefined"!=typeof performance&&"number"==typeof performance.timeOrigin){const t=performance.timeOrigin,r=performance.now();return Math.ceil((t+r)/bt)}return Date.now()},timestamp64:Et,lapseNano:Nt,lapseMillis:$t,timeoutNano:function(t,r){return Nt(t)>r},timeoutMillis:function(t,r){return $t(t)>r}};function Et(){if("undefined"!=typeof performance&&"number"==typeof performance.timeOrigin){const t=performance.timeOrigin,r=performance.now();return BigInt((t+r)*bt)}return BigInt(Date.now()*bt)}function Nt(t,r){return(r??Et())-t}function $t(t,r){r=r??Et();return BigInt(r-t)/BigInt(bt)}var Ot={first:function(t,r){return _(t,"arr"),t[0]??r},chunk:function(t,r){if(_(t,"array"),J(r,"size"),t.length<=r)return t;const e=[];let n=0;for(;n<t.length;)e.push(t.slice(n,r+n)),n+=r;return e},last:function(t,r){return _(t,"arr"),t[t.length-1]??r},equals:function(t,r,e){if(!Array.isArray(t)||!Array.isArray(r))return!1;if(t.length!==r.length)return!1;for(let n=0;n<t.length;n++)if(e){if(0!==e(t[n],r[n]))return!1}else if(t[n]!==r[n])return!1;return!0},equalsIgnoreOrder:function(t,r,e){if(!Array.isArray(t)||!Array.isArray(r))return!1;if(t.length!==r.length)return!1;t.sort(e),r.sort(e);for(let n=0;n<t.length;n++)if(e){if(0!==e(t[n],r[n]))return!1}else if(t[n]!==r[n])return!1;return!0}};var vt={take:function(t,r){const e=[];let n;for(let o=0;o<r&&!(n=t.next()).done;o++)e.push(n.value);return e}},Pt={_Error:e,AggregatedError:n,LangUtils:o,StringUtils:Y,TypeUtils:f,TypeAssert:D,ExecUtils:et,PromiseUtils:nt,Lang:o,Type:f,Exec:et,ClassProxyUtils:ft,InstanceProxyUtils:ct,ReflectUtils:yt,TypedArrayUtils:pt,ArrayBufferUtils:dt,TimeUtils:At,ArrayUtils:Ot,IteratorUtils:vt};t.AggregatedError=n,t.ArrayBufferUtils=dt,t.ArrayUtils=Ot,t.ClassProxyUtils=ft,t.Exec=et,t.ExecUtils=et,t.InstanceProxyUtils=ct,t.IteratorUtils=vt,t.Lang=o,t.LangUtils=o,t.PromiseUtils=nt,t.ReflectUtils=yt,t.StringUtils=Y,t.TimeUtils=At,t.Type=f,t.TypeAssert=D,t.TypeUtils=f,t.TypedArrayUtils=pt,t._Error=e,t.default=Pt,Object.defineProperty(t,"__esModule",{value:!0})});
2
2
  //# sourceMappingURL=index.min.js.map