tiny-essentials 1.5.1 → 1.6.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.
@@ -2988,6 +2988,7 @@ class TinyPromiseQueue {
2988
2988
  * @property {(value: any) => any} resolve - The resolve function from the Promise.
2989
2989
  * @property {(reason?: any) => any} reject - The reject function from the Promise.
2990
2990
  * @property {string|undefined} [id] - Optional identifier for the task.
2991
+ * @property {string|null|undefined} [marker] - Optional marker for the task.
2991
2992
  * @property {number|null|undefined} [delay] - Optional delay (in ms) before the task is executed.
2992
2993
  */
2993
2994
 
@@ -3009,15 +3010,13 @@ class TinyPromiseQueue {
3009
3010
  }
3010
3011
 
3011
3012
  /**
3012
- * Processes the next task in the queue if not already running.
3013
- * Ensures tasks are executed in order, one at a time.
3013
+ * Processes the a normal task.
3014
+ *
3015
+ * @param {QueuedTask} data
3014
3016
  *
3015
3017
  * @returns {Promise<void>}
3016
3018
  */
3017
- async #processQueue() {
3018
- if (this.#running || this.#queue.length === 0) return;
3019
- this.#running = true;
3020
- const data = this.#queue.shift();
3019
+ async #normalProcessQueue(data) {
3021
3020
  if (
3022
3021
  data &&
3023
3022
  typeof data.task === 'function' &&
@@ -3026,6 +3025,14 @@ class TinyPromiseQueue {
3026
3025
  ) {
3027
3026
  const { task, resolve, reject, delay, id } = data;
3028
3027
  try {
3028
+ if (id && this.#blacklist.has(id)) {
3029
+ reject(new Error('The function was canceled on TinyPromiseQueue.'));
3030
+ this.#blacklist.delete(id);
3031
+ this.#running = false;
3032
+ this.#processQueue();
3033
+ return;
3034
+ }
3035
+
3029
3036
  if (delay && id) {
3030
3037
  await new Promise((resolveDelay) => {
3031
3038
  const timeoutId = setTimeout(() => {
@@ -3036,14 +3043,6 @@ class TinyPromiseQueue {
3036
3043
  });
3037
3044
  }
3038
3045
 
3039
- if (id && this.#blacklist.has(id)) {
3040
- reject(new Error('The function was canceled on TinyPromiseQueue.'));
3041
- this.#blacklist.delete(id);
3042
- this.#running = false;
3043
- this.#processQueue();
3044
- return;
3045
- }
3046
-
3047
3046
  const result = await task();
3048
3047
  resolve(result);
3049
3048
  } catch (error) {
@@ -3055,6 +3054,61 @@ class TinyPromiseQueue {
3055
3054
  }
3056
3055
  }
3057
3056
 
3057
+ /**
3058
+ * Processes a group task.
3059
+ *
3060
+ * @returns {Promise<void>}
3061
+ */
3062
+ async #groupProcessQueue() {
3063
+ /** @type {Array<QueuedTask>} */
3064
+ const grouped = [];
3065
+ while (this.#queue.length && this.#queue[0]?.marker === 'POINT_MARKER') {
3066
+ // @ts-ignore
3067
+ grouped.push(this.#queue.shift());
3068
+ }
3069
+
3070
+ if (grouped.length === 0) {
3071
+ this.#running = false;
3072
+ this.#processQueue();
3073
+ return;
3074
+ }
3075
+
3076
+ await Promise.all(
3077
+ grouped.map(
3078
+ ({ task, resolve, reject, id }) =>
3079
+ new Promise(async (pResolve) => {
3080
+ if (id && this.#blacklist.has(id)) {
3081
+ this.#blacklist.delete(id);
3082
+ reject(new Error('The function was canceled on TinyPromiseQueue.'));
3083
+ pResolve(true);
3084
+ return;
3085
+ }
3086
+ await task().then(resolve).catch(reject);
3087
+ pResolve(true);
3088
+ }),
3089
+ ),
3090
+ );
3091
+
3092
+ this.#running = false;
3093
+ this.#processQueue();
3094
+ }
3095
+
3096
+ /**
3097
+ * Processes the next task in the queue if not already running.
3098
+ * Ensures tasks are executed in order, one at a time.
3099
+ *
3100
+ * @returns {Promise<void>}
3101
+ */
3102
+ async #processQueue() {
3103
+ if (this.#running || this.#queue.length === 0) return;
3104
+ this.#running = true;
3105
+ if (typeof this.#queue[0]?.marker !== 'string' || this.#queue[0]?.marker !== 'POINT_MARKER') {
3106
+ const data = this.#queue.shift();
3107
+ // @ts-ignore
3108
+ this.#normalProcessQueue(data);
3109
+ } else this.#groupProcessQueue();
3110
+ }
3111
+
3058
3112
  /**
3059
3113
  * Returns the index of a task by its ID.
3060
3114
  *
@@ -3097,6 +3151,22 @@ class TinyPromiseQueue {
3097
3151
  this.#queue.splice(toIndex, 0, item);
3098
3152
  }
3099
3153
 
3154
+ /**
3155
+ * Inserts a point in the queue where subsequent tasks will be grouped and executed together in a Promise.all.
3156
+ * If the queue is currently empty, behaves like a regular promise.
3157
+ *
3158
+ * @param {(...args: any[]) => Promise<any>|Promise<any>} task A function that returns a Promise.
3159
+ * @param {string} [id] Optional ID to identify the task in the queue.
3160
+ * @returns {Promise<any>} A Promise that resolves or rejects with the result of the task once it's processed.
3161
+ */
3162
+ async enqueuePoint(task, id) {
3163
+ if (!this.#running) return task();
3164
+ return new Promise((resolve, reject) => {
3165
+ this.#queue.push({ marker: 'POINT_MARKER', task, resolve, reject, id });
3166
+ this.#processQueue();
3167
+ });
3168
+ }
3169
+
3100
3170
  /**
3101
3171
  * Adds a new async task to the queue and ensures it runs in order after previous tasks.
3102
3172
  * Optionally, a delay can be added before the task is executed.
@@ -3135,7 +3205,8 @@ class TinyPromiseQueue {
3135
3205
 
3136
3206
  const index = this.getIndexById(id);
3137
3207
  if (index !== -1) {
3138
- this.#queue.splice(index, 1);
3208
+ const [removed] = this.#queue.splice(index, 1);
3209
+ removed?.reject?.(new Error('The function was canceled on TinyPromiseQueue.'));
3139
3210
  cancelled = true;
3140
3211
  }
3141
3212
 
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see TinyEssentials.min.js.LICENSE.txt */
2
- (()=>{var t={251:(t,e)=>{e.read=function(t,e,r,n,o){var i,s,u=8*o-n-1,f=(1<<u)-1,a=f>>1,h=-7,l=r?o-1:0,c=r?-1:1,p=t[e+l];for(l+=c,i=p&(1<<-h)-1,p>>=-h,h+=u;h>0;i=256*i+t[e+l],l+=c,h-=8);for(s=i&(1<<-h)-1,i>>=-h,h+=n;h>0;s=256*s+t[e+l],l+=c,h-=8);if(0===i)i=1-a;else{if(i===f)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),i-=a}return(p?-1:1)*s*Math.pow(2,i-n)},e.write=function(t,e,r,n,o,i){var s,u,f,a=8*i-o-1,h=(1<<a)-1,l=h>>1,c=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,y=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(u=isNaN(e)?1:0,s=h):(s=Math.floor(Math.log(e)/Math.LN2),e*(f=Math.pow(2,-s))<1&&(s--,f*=2),(e+=s+l>=1?c/f:c*Math.pow(2,1-l))*f>=2&&(s++,f/=2),s+l>=h?(u=0,s=h):s+l>=1?(u=(e*f-1)*Math.pow(2,o),s+=l):(u=e*Math.pow(2,l-1)*Math.pow(2,o),s=0));o>=8;t[r+p]=255&u,p+=y,u/=256,o-=8);for(s=s<<o|u,a+=o;a>0;t[r+p]=255&s,p+=y,s/=256,a-=8);t[r+p-y]|=128*g}},287:(t,e,r)=>{"use strict";var n=r(526),o=r(251),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.hp=f,e.IS=50;var s=2147483647;function u(t){if(t>s)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return Object.setPrototypeOf(e,f.prototype),e}function f(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return l(t)}return a(t,e,r)}function a(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!f.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|g(t,e),n=u(r),o=n.write(t,e);return o!==r&&(n=n.slice(0,o)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(Y(t,Uint8Array)){var e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return c(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(Y(t,ArrayBuffer)||t&&Y(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(Y(t,SharedArrayBuffer)||t&&Y(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');var n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return f.from(n,e,r);var o=function(t){if(f.isBuffer(t)){var e=0|y(t.length),r=u(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||_(t.length)?u(0):c(t):"Buffer"===t.type&&Array.isArray(t.data)?c(t.data):void 0}(t);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return f.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function h(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function l(t){return h(t),u(t<0?0:0|y(t))}function c(t){for(var e=t.length<0?0:0|y(t.length),r=u(e),n=0;n<e;n+=1)r[n]=255&t[n];return r}function p(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');var n;return n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(n,f.prototype),n}function y(t){if(t>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|t}function g(t,e){if(f.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Y(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var o=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return D(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(o)return n?-1:D(t).length;e=(""+e).toLowerCase(),o=!0}}function d(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return S(this,e,r);case"utf8":case"utf-8":return U(this,e,r);case"ascii":return M(this,e,r);case"latin1":case"binary":return O(this,e,r);case"base64":return T(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return N(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function m(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function w(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),_(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=f.from(e,n)),f.isBuffer(e))return 0===e.length?-1:v(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):v(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function v(t,e,r,n,o){var i,s=1,u=t.length,f=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,u/=2,f/=2,r/=2}function a(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(o){var h=-1;for(i=r;i<u;i++)if(a(t,i)===a(e,-1===h?0:i-h)){if(-1===h&&(h=i),i-h+1===f)return h*s}else-1!==h&&(i-=i-h),h=-1}else for(r+f>u&&(r=u-f),i=r;i>=0;i--){for(var l=!0,c=0;c<f;c++)if(a(t,i+c)!==a(e,c)){l=!1;break}if(l)return i}return-1}function b(t,e,r,n){r=Number(r)||0;var o=t.length-r;n?(n=Number(n))>o&&(n=o):n=o;var i=e.length;n>i/2&&(n=i/2);for(var s=0;s<n;++s){var u=parseInt(e.substr(2*s,2),16);if(_(u))return s;t[r+s]=u}return s}function E(t,e,r,n){return q(D(e,t.length-r),t,r,n)}function A(t,e,r,n){return q(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function x(t,e,r,n){return q(F(e),t,r,n)}function B(t,e,r,n){return q(function(t,e){for(var r,n,o,i=[],s=0;s<t.length&&!((e-=2)<0);++s)n=(r=t.charCodeAt(s))>>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function T(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function U(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o<r;){var i,s,u,f,a=t[o],h=null,l=a>239?4:a>223?3:a>191?2:1;if(o+l<=r)switch(l){case 1:a<128&&(h=a);break;case 2:128==(192&(i=t[o+1]))&&(f=(31&a)<<6|63&i)>127&&(h=f);break;case 3:i=t[o+1],s=t[o+2],128==(192&i)&&128==(192&s)&&(f=(15&a)<<12|(63&i)<<6|63&s)>2047&&(f<55296||f>57343)&&(h=f);break;case 4:i=t[o+1],s=t[o+2],u=t[o+3],128==(192&i)&&128==(192&s)&&128==(192&u)&&(f=(15&a)<<18|(63&i)<<12|(63&s)<<6|63&u)>65535&&f<1114112&&(h=f)}null===h?(h=65533,l=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),o+=l}return function(t){var e=t.length;if(e<=L)return String.fromCharCode.apply(String,t);for(var r="",n=0;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=L));return r}(n)}f.TYPED_ARRAY_SUPPORT=function(){try{var t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),f.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(f.prototype,"parent",{enumerable:!0,get:function(){if(f.isBuffer(this))return this.buffer}}),Object.defineProperty(f.prototype,"offset",{enumerable:!0,get:function(){if(f.isBuffer(this))return this.byteOffset}}),f.poolSize=8192,f.from=function(t,e,r){return a(t,e,r)},Object.setPrototypeOf(f.prototype,Uint8Array.prototype),Object.setPrototypeOf(f,Uint8Array),f.alloc=function(t,e,r){return function(t,e,r){return h(t),t<=0?u(t):void 0!==e?"string"==typeof r?u(t).fill(e,r):u(t).fill(e):u(t)}(t,e,r)},f.allocUnsafe=function(t){return l(t)},f.allocUnsafeSlow=function(t){return l(t)},f.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==f.prototype},f.compare=function(t,e){if(Y(t,Uint8Array)&&(t=f.from(t,t.offset,t.byteLength)),Y(e,Uint8Array)&&(e=f.from(e,e.offset,e.byteLength)),!f.isBuffer(t)||!f.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;for(var r=t.length,n=e.length,o=0,i=Math.min(r,n);o<i;++o)if(t[o]!==e[o]){r=t[o],n=e[o];break}return r<n?-1:n<r?1:0},f.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},f.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return f.alloc(0);var r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var n=f.allocUnsafe(e),o=0;for(r=0;r<t.length;++r){var i=t[r];if(Y(i,Uint8Array))o+i.length>n.length?f.from(i).copy(n,o):Uint8Array.prototype.set.call(n,i,o);else{if(!f.isBuffer(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(n,o)}o+=i.length}return n},f.byteLength=g,f.prototype._isBuffer=!0,f.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)m(this,e,e+1);return this},f.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)m(this,e,e+3),m(this,e+1,e+2);return this},f.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)m(this,e,e+7),m(this,e+1,e+6),m(this,e+2,e+5),m(this,e+3,e+4);return this},f.prototype.toString=function(){var t=this.length;return 0===t?"":0===arguments.length?U(this,0,t):d.apply(this,arguments)},f.prototype.toLocaleString=f.prototype.toString,f.prototype.equals=function(t){if(!f.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===f.compare(this,t)},f.prototype.inspect=function(){var t="",r=e.IS;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},i&&(f.prototype[i]=f.prototype.inspect),f.prototype.compare=function(t,e,r,n,o){if(Y(t,Uint8Array)&&(t=f.from(t,t.offset,t.byteLength)),!f.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0),u=Math.min(i,s),a=this.slice(n,o),h=t.slice(e,r),l=0;l<u;++l)if(a[l]!==h[l]){i=a[l],s=h[l];break}return i<s?-1:s<i?1:0},f.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},f.prototype.indexOf=function(t,e,r){return w(this,t,e,r,!0)},f.prototype.lastIndexOf=function(t,e,r){return w(this,t,e,r,!1)},f.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return b(this,t,e,r);case"utf8":case"utf-8":return E(this,t,e,r);case"ascii":case"latin1":case"binary":return A(this,t,e,r);case"base64":return x(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},f.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var L=4096;function M(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;o<r;++o)n+=String.fromCharCode(127&t[o]);return n}function O(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;o<r;++o)n+=String.fromCharCode(t[o]);return n}function S(t,e,r){var n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);for(var o="",i=e;i<r;++i)o+=z[t[i]];return o}function N(t,e,r){for(var n=t.slice(e,r),o="",i=0;i<n.length-1;i+=2)o+=String.fromCharCode(n[i]+256*n[i+1]);return o}function I(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function C(t,e,r,n,o,i){if(!f.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<i)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function j(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function k(t,e,r,n,i){return e=+e,r>>>=0,i||j(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function R(t,e,r,n,i){return e=+e,r>>>=0,i||j(t,0,r,8),o.write(t,e,r,n,52,8),r+8}f.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);var n=this.subarray(t,e);return Object.setPrototypeOf(n,f.prototype),n},f.prototype.readUintLE=f.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||I(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return n},f.prototype.readUintBE=f.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||I(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},f.prototype.readUint8=f.prototype.readUInt8=function(t,e){return t>>>=0,e||I(t,1,this.length),this[t]},f.prototype.readUint16LE=f.prototype.readUInt16LE=function(t,e){return t>>>=0,e||I(t,2,this.length),this[t]|this[t+1]<<8},f.prototype.readUint16BE=f.prototype.readUInt16BE=function(t,e){return t>>>=0,e||I(t,2,this.length),this[t]<<8|this[t+1]},f.prototype.readUint32LE=f.prototype.readUInt32LE=function(t,e){return t>>>=0,e||I(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},f.prototype.readUint32BE=f.prototype.readUInt32BE=function(t,e){return t>>>=0,e||I(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},f.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||I(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return n>=(o*=128)&&(n-=Math.pow(2,8*e)),n},f.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||I(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},f.prototype.readInt8=function(t,e){return t>>>=0,e||I(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},f.prototype.readInt16LE=function(t,e){t>>>=0,e||I(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},f.prototype.readInt16BE=function(t,e){t>>>=0,e||I(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},f.prototype.readInt32LE=function(t,e){return t>>>=0,e||I(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},f.prototype.readInt32BE=function(t,e){return t>>>=0,e||I(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},f.prototype.readFloatLE=function(t,e){return t>>>=0,e||I(t,4,this.length),o.read(this,t,!0,23,4)},f.prototype.readFloatBE=function(t,e){return t>>>=0,e||I(t,4,this.length),o.read(this,t,!1,23,4)},f.prototype.readDoubleLE=function(t,e){return t>>>=0,e||I(t,8,this.length),o.read(this,t,!0,52,8)},f.prototype.readDoubleBE=function(t,e){return t>>>=0,e||I(t,8,this.length),o.read(this,t,!1,52,8)},f.prototype.writeUintLE=f.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||C(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i<r&&(o*=256);)this[e+i]=t/o&255;return e+r},f.prototype.writeUintBE=f.prototype.writeUIntBE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||C(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},f.prototype.writeUint8=f.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,1,255,0),this[e]=255&t,e+1},f.prototype.writeUint16LE=f.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},f.prototype.writeUint16BE=f.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},f.prototype.writeUint32LE=f.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},f.prototype.writeUint32BE=f.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},f.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);C(this,t,e,r,o-1,-o)}var i=0,s=1,u=0;for(this[e]=255&t;++i<r&&(s*=256);)t<0&&0===u&&0!==this[e+i-1]&&(u=1),this[e+i]=(t/s|0)-u&255;return e+r},f.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);C(this,t,e,r,o-1,-o)}var i=r-1,s=1,u=0;for(this[e+i]=255&t;--i>=0&&(s*=256);)t<0&&0===u&&0!==this[e+i+1]&&(u=1),this[e+i]=(t/s|0)-u&255;return e+r},f.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},f.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},f.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},f.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},f.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},f.prototype.writeFloatLE=function(t,e,r){return k(this,t,e,!0,r)},f.prototype.writeFloatBE=function(t,e,r){return k(this,t,e,!1,r)},f.prototype.writeDoubleLE=function(t,e,r){return R(this,t,e,!0,r)},f.prototype.writeDoubleBE=function(t,e,r){return R(this,t,e,!1,r)},f.prototype.copy=function(t,e,r,n){if(!f.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);var o=n-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,n):Uint8Array.prototype.set.call(t,this.subarray(r,n),e),o},f.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!f.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var o=t.charCodeAt(0);("utf8"===n&&o<128||"latin1"===n)&&(t=o)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;var i;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i<r;++i)this[i]=t;else{var s=f.isBuffer(t)?t:f.from(t,n),u=s.length;if(0===u)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<r-e;++i)this[i+e]=s[i%u]}return this};var P=/[^+/0-9A-Za-z-_]/g;function D(t,e){var r;e=e||1/0;for(var n=t.length,o=null,i=[],s=0;s<n;++s){if((r=t.charCodeAt(s))>55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function F(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(P,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function q(t,e,r,n){for(var o=0;o<n&&!(o+r>=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function Y(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function _(t){return t!=t}var z=function(){for(var t="0123456789abcdef",e=new Array(256),r=0;r<16;++r)for(var n=16*r,o=0;o<16;++o)e[n+o]=t[r]+t[o];return e}()},526:(t,e)=>{"use strict";e.byteLength=function(t){var e=u(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,i=u(t),s=i[0],f=i[1],a=new o(function(t,e,r){return 3*(e+r)/4-r}(0,s,f)),h=0,l=f>0?s-4:s;for(r=0;r<l;r+=4)e=n[t.charCodeAt(r)]<<18|n[t.charCodeAt(r+1)]<<12|n[t.charCodeAt(r+2)]<<6|n[t.charCodeAt(r+3)],a[h++]=e>>16&255,a[h++]=e>>8&255,a[h++]=255&e;return 2===f&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,a[h++]=255&e),1===f&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,a[h++]=e>>8&255,a[h++]=255&e),a},e.fromByteArray=function(t){for(var e,n=t.length,o=n%3,i=[],s=16383,u=0,a=n-o;u<a;u+=s)i.push(f(t,u,u+s>a?a:u+s));return 1===o?(e=t[n-1],i.push(r[e>>2]+r[e<<4&63]+"==")):2===o&&(e=(t[n-2]<<8)+t[n-1],i.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"=")),i.join("")};for(var r=[],n=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0;s<64;++s)r[s]=i[s],n[i.charCodeAt(s)]=s;function u(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function f(t,e,n){for(var o,i,s=[],u=e;u<n;u+=3)o=(t[u]<<16&16711680)+(t[u+1]<<8&65280)+(255&t[u+2]),s.push(r[(i=o)>>18&63]+r[i>>12&63]+r[i>>6&63]+r[63&i]);return s.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63}},e={};function r(n){var o=e[n];if(void 0!==o)return o.exports;var i=e[n]={exports:{}};return t[n](i,i.exports,r),i.exports}r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};(()=>{"use strict";async function t(t,e,r){const n=[];t.replace(e,((t,...e)=>(n.push(r(t,...e)),t)));const o=await Promise.all(n);return t.replace(e,(()=>o.shift()))}r.r(n),r.d(n,{TinyLevelUp:()=>e,TinyPromiseQueue:()=>x,asyncReplace:()=>t,checkObj:()=>d,cloneObjTypeOrder:()=>p,countObj:()=>m,extendObjType:()=>l,formatCustomTimer:()=>s,formatDayTimer:()=>f,formatTimer:()=>u,getAge:()=>b,getSimplePerc:()=>v,getTimeDuration:()=>i,objType:()=>g,reorderObjTypeOrder:()=>c,ruleOfThree:()=>w,shuffleArray:()=>o,toTitleCase:()=>E,toTitleCaseLowerFirst:()=>A});const e=class{constructor(t,e){this.giveExp=t,this.expLevel=e}expValidator(t){let e=0;const r=this.expLevel*t.level;return t.exp>=r&&(t.level++,e=t.exp-r,t.exp=0,e>0)?this.give(t,e,"extra"):t.exp<1&&t.level>1&&(t.level--,e=Math.abs(t.exp),t.exp=this.expLevel*t.level,e>0)?this.remove(t,e,"extra"):t}getTotalExp(t){let e=0;for(let r=1;r<=t.level;r++)e+=this.expLevel*r;return e+=t.exp,e}expGenerator(t=1){return Math.floor(Math.random()*this.giveExp)+1*t}progress(t){return this.expLevel*t.level}getProgress(t){return this.expLevel*t.level}set(t,e){return t.exp=e,this.expValidator(t),t.totalExp=this.getTotalExp(t),t}give(t,e=0,r="add",n=1){return"add"===r?t.exp+=this.expGenerator(n)+e:"extra"===r&&(t.exp+=e),this.expValidator(t),t.totalExp=this.getTotalExp(t),t}remove(t,e=0,r="add",n=1){return"add"===r?t.exp-=this.expGenerator(n)+e:"extra"===r&&(t.exp-=e),this.expValidator(t),t.totalExp=this.getTotalExp(t),t}};function o(t){let e,r=t.length;for(;0!==r;)e=Math.floor(Math.random()*r),r--,[t[r],t[e]]=[t[e],t[r]];return t}function i(t=new Date,e="asSeconds",r=null){if(t instanceof Date){const n=r instanceof Date?r:new Date,o=t.getTime()-n.getTime();switch(e){case"asMilliseconds":return o;case"asSeconds":default:return o/1e3;case"asMinutes":return o/6e4;case"asHours":return o/36e5;case"asDays":return o/864e5}}return null}function s(t,e="seconds",r="{time}"){t=Math.max(0,Math.floor(t));const n=["seconds","minutes","hours","days","months","years"].indexOf(e),o=n>=5,i=n>=4,s=n>=3,u=n>=2,f=n>=1,a=n>=0,h={years:o?0:NaN,months:i?0:NaN,days:s?0:NaN,hours:u?0:NaN,minutes:f?0:NaN,seconds:a?0:NaN,total:NaN};let l=t;if(o||i||s){const t=new Date(1980,0,1),e=new Date(t.getTime()+1e3*l),r=new Date(t);if(o)for(;new Date(r.getFullYear()+1,r.getMonth(),r.getDate()).getTime()<=e.getTime();)r.setFullYear(r.getFullYear()+1),h.years++;if(i)for(;new Date(r.getFullYear(),r.getMonth()+1,r.getDate()).getTime()<=e.getTime();)r.setMonth(r.getMonth()+1),h.months++;if(s)for(;new Date(r.getFullYear(),r.getMonth(),r.getDate()+1).getTime()<=e.getTime();)r.setDate(r.getDate()+1),h.days++;l=Math.floor((e.getTime()-r.getTime())/1e3)}u&&(h.hours=Math.floor(l/3600),l%=3600),f&&(h.minutes=Math.floor(l/60),l%=60),a&&(h.seconds=l);const c={seconds:a?t:NaN,minutes:f?t/60:NaN,hours:u?t/3600:NaN,days:s?t/86400:NaN,months:i?12*h.years+h.months+(h.days||0)/30:NaN,years:o?h.years+(h.months||0)/12+(h.days||0)/365:NaN};h.total=+(c[e]||0).toFixed(2).replace(/\.00$/,"");const p=t=>{const e="string"==typeof t?parseInt(t):t;return Number.isNaN(e)?"NaN":String(e).padStart(2,"0")},y=[u?p(h.hours):null,f?p(h.minutes):null,a?p(h.seconds):null].filter((t=>null!==t)).join(":");return r.replace(/\{years\}/g,String(h.years)).replace(/\{months\}/g,String(h.months)).replace(/\{days\}/g,String(h.days)).replace(/\{hours\}/g,p(h.hours)).replace(/\{minutes\}/g,p(h.minutes)).replace(/\{seconds\}/g,p(h.seconds)).replace(/\{time\}/g,y).replace(/\{total\}/g,String(h.total)).trim()}function u(t){return s(t,"hours","{hours}:{minutes}:{seconds}")}function f(t){return s(t,"days","{days}d {hours}:{minutes}:{seconds}")}var a=r(287);const h={items:{undefined:t=>void 0===t,null:t=>null===t,boolean:t=>"boolean"==typeof t,number:t=>"number"==typeof t&&!isNaN(t),bigint:t=>"bigint"==typeof t,string:t=>"string"==typeof t,symbol:t=>"symbol"==typeof t,function:t=>"function"==typeof t,array:t=>Array.isArray(t),date:t=>t instanceof Date,regexp:t=>t instanceof RegExp,map:t=>t instanceof Map,set:t=>t instanceof Set,weakmap:t=>t instanceof WeakMap,weakset:t=>t instanceof WeakSet,promise:t=>t instanceof Promise,buffer:t=>void 0!==a.hp&&a.hp.isBuffer(t),file:t=>"undefined"!=typeof File&&t instanceof File,htmlelement:t=>"undefined"!=typeof HTMLElement&&t instanceof HTMLElement,object:t=>"object"==typeof t&&null!==t},order:["undefined","null","boolean","number","bigint","string","symbol","function","array","buffer","file","date","regexp","map","set","weakmap","weakset","promise","htmlelement","object"]};function l(t,e){const r=[];for(const[n,o]of Object.entries(t))if(!h.items.hasOwnProperty(n)){h.items[n]=o;let t="number"==typeof e?e:-1;if(-1===t){const e=h.order.indexOf("object");t=e>-1?e:h.order.length}t=Math.min(Math.max(0,t),h.order.length),h.order.splice(t,0,n),r.push(n)}return r}function c(t){const e=[...h.order];return!!t.every((t=>e.includes(t)))&&(h.order=t.slice(),!0)}function p(){return[...h.order]}const y=t=>{if(null===t)return"null";for(const e of h.order)if("function"!=typeof h.items[e]||h.items[e](t))return e;return"unknown"};function g(t,e){if(void 0===t)return null;const r=y(t);return"string"==typeof e?r===e.toLowerCase():r}function d(t){const e={valid:null,type:null};for(const r of h.order)if("function"==typeof h.items[r]){const n=h.items[r](t);if(n){e.valid=n,e.type=r;break}}return e}function m(t){return Array.isArray(t)?t.length:g(t,"object")?Object.keys(t).length:0}function w(t,e,r,n=!1){return n?Number(t*e)/r:Number(r*e)/t}function v(t,e){return t*(e/100)}function b(t=0,e=null){if(null!=t&&0!==t){const r=new Date(t);if(Number.isNaN(r.getTime()))return null;const n=e instanceof Date?e:new Date;let o=n.getFullYear()-r.getFullYear();const i=n.getMonth(),s=r.getMonth(),u=n.getDate(),f=r.getDate();return(i<s||i===s&&u<f)&&o--,Math.abs(o)}return null}function E(t){return t.replace(/\w\S*/g,(t=>t.charAt(0).toUpperCase()+t.substr(1).toLowerCase()))}function A(t){const e=t.replace(/\w\S*/g,(t=>t.charAt(0).toUpperCase()+t.substr(1).toLowerCase()));return e.charAt(0).toLowerCase()+e.slice(1)}const x=class{#t=[];#e=!1;#r={};#n=new Set;isRunning(){return this.#e}async#o(){if(this.#e||0===this.#t.length)return;this.#e=!0;const t=this.#t.shift();if(t&&"function"==typeof t.task&&"function"==typeof t.resolve&&"function"==typeof t.reject){const{task:e,resolve:r,reject:n,delay:o,id:i}=t;try{if(o&&i&&await new Promise((t=>{const e=setTimeout((()=>{delete this.#r[i],t(null)}),o);this.#r[i]=e})),i&&this.#n.has(i))return n(new Error("The function was canceled on TinyPromiseQueue.")),this.#n.delete(i),this.#e=!1,void this.#o();r(await e())}catch(t){n(t)}finally{this.#e=!1,this.#o()}}}getIndexById(t){return this.#t.findIndex((e=>e.id===t))}getQueuedIds(){return this.#t.map(((t,e)=>({index:e,id:t.id}))).filter((t=>"string"==typeof t.id))}reorderQueue(t,e){if("number"!=typeof t||"number"!=typeof e||t<0||e<0||t>=this.#t.length||e>=this.#t.length)return;const[r]=this.#t.splice(t,1);this.#t.splice(e,0,r)}enqueue(t,e,r){return new Promise(((n,o)=>{this.#t.push({task:t,resolve:n,reject:o,id:r,delay:e}),this.#o()}))}cancelTask(t){if(!t)return!1;let e=!1;t in this.#r&&(clearTimeout(this.#r[t]),delete this.#r[t],e=!0);const r=this.getIndexById(t);return-1!==r&&(this.#t.splice(r,1),e=!0),e&&this.#n.add(t),e}}})(),window.TinyEssentials=n})();
2
+ (()=>{var t={251:(t,e)=>{e.read=function(t,e,r,n,o){var i,s,u=8*o-n-1,a=(1<<u)-1,f=a>>1,h=-7,l=r?o-1:0,c=r?-1:1,p=t[e+l];for(l+=c,i=p&(1<<-h)-1,p>>=-h,h+=u;h>0;i=256*i+t[e+l],l+=c,h-=8);for(s=i&(1<<-h)-1,i>>=-h,h+=n;h>0;s=256*s+t[e+l],l+=c,h-=8);if(0===i)i=1-f;else{if(i===a)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),i-=f}return(p?-1:1)*s*Math.pow(2,i-n)},e.write=function(t,e,r,n,o,i){var s,u,a,f=8*i-o-1,h=(1<<f)-1,l=h>>1,c=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,y=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(u=isNaN(e)?1:0,s=h):(s=Math.floor(Math.log(e)/Math.LN2),e*(a=Math.pow(2,-s))<1&&(s--,a*=2),(e+=s+l>=1?c/a:c*Math.pow(2,1-l))*a>=2&&(s++,a/=2),s+l>=h?(u=0,s=h):s+l>=1?(u=(e*a-1)*Math.pow(2,o),s+=l):(u=e*Math.pow(2,l-1)*Math.pow(2,o),s=0));o>=8;t[r+p]=255&u,p+=y,u/=256,o-=8);for(s=s<<o|u,f+=o;f>0;t[r+p]=255&s,p+=y,s/=256,f-=8);t[r+p-y]|=128*g}},287:(t,e,r)=>{"use strict";var n=r(526),o=r(251),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.hp=a,e.IS=50;var s=2147483647;function u(t){if(t>s)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return Object.setPrototypeOf(e,a.prototype),e}function a(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return l(t)}return f(t,e,r)}function f(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!a.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|g(t,e),n=u(r),o=n.write(t,e);return o!==r&&(n=n.slice(0,o)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(Q(t,Uint8Array)){var e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return c(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(Q(t,ArrayBuffer)||t&&Q(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(Q(t,SharedArrayBuffer)||t&&Q(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');var n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return a.from(n,e,r);var o=function(t){if(a.isBuffer(t)){var e=0|y(t.length),r=u(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||_(t.length)?u(0):c(t):"Buffer"===t.type&&Array.isArray(t.data)?c(t.data):void 0}(t);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return a.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function h(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function l(t){return h(t),u(t<0?0:0|y(t))}function c(t){for(var e=t.length<0?0:0|y(t.length),r=u(e),n=0;n<e;n+=1)r[n]=255&t[n];return r}function p(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');var n;return n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(n,a.prototype),n}function y(t){if(t>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|t}function g(t,e){if(a.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Q(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var o=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return D(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return q(t).length;default:if(o)return n?-1:D(t).length;e=(""+e).toLowerCase(),o=!0}}function d(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return N(this,e,r);case"utf8":case"utf-8":return U(this,e,r);case"ascii":return O(this,e,r);case"latin1":case"binary":return L(this,e,r);case"base64":return B(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function m(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function w(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),_(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=a.from(e,n)),a.isBuffer(e))return 0===e.length?-1:v(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):v(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function v(t,e,r,n,o){var i,s=1,u=t.length,a=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,u/=2,a/=2,r/=2}function f(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(o){var h=-1;for(i=r;i<u;i++)if(f(t,i)===f(e,-1===h?0:i-h)){if(-1===h&&(h=i),i-h+1===a)return h*s}else-1!==h&&(i-=i-h),h=-1}else for(r+a>u&&(r=u-a),i=r;i>=0;i--){for(var l=!0,c=0;c<a;c++)if(f(t,i+c)!==f(e,c)){l=!1;break}if(l)return i}return-1}function b(t,e,r,n){r=Number(r)||0;var o=t.length-r;n?(n=Number(n))>o&&(n=o):n=o;var i=e.length;n>i/2&&(n=i/2);for(var s=0;s<n;++s){var u=parseInt(e.substr(2*s,2),16);if(_(u))return s;t[r+s]=u}return s}function E(t,e,r,n){return F(D(e,t.length-r),t,r,n)}function A(t,e,r,n){return F(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function T(t,e,r,n){return F(q(e),t,r,n)}function x(t,e,r,n){return F(function(t,e){for(var r,n,o,i=[],s=0;s<t.length&&!((e-=2)<0);++s)n=(r=t.charCodeAt(s))>>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function B(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function U(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o<r;){var i,s,u,a,f=t[o],h=null,l=f>239?4:f>223?3:f>191?2:1;if(o+l<=r)switch(l){case 1:f<128&&(h=f);break;case 2:128==(192&(i=t[o+1]))&&(a=(31&f)<<6|63&i)>127&&(h=a);break;case 3:i=t[o+1],s=t[o+2],128==(192&i)&&128==(192&s)&&(a=(15&f)<<12|(63&i)<<6|63&s)>2047&&(a<55296||a>57343)&&(h=a);break;case 4:i=t[o+1],s=t[o+2],u=t[o+3],128==(192&i)&&128==(192&s)&&128==(192&u)&&(a=(15&f)<<18|(63&i)<<12|(63&s)<<6|63&u)>65535&&a<1114112&&(h=a)}null===h?(h=65533,l=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),o+=l}return function(t){var e=t.length;if(e<=M)return String.fromCharCode.apply(String,t);for(var r="",n=0;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=M));return r}(n)}a.TYPED_ARRAY_SUPPORT=function(){try{var t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),a.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}}),a.poolSize=8192,a.from=function(t,e,r){return f(t,e,r)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array),a.alloc=function(t,e,r){return function(t,e,r){return h(t),t<=0?u(t):void 0!==e?"string"==typeof r?u(t).fill(e,r):u(t).fill(e):u(t)}(t,e,r)},a.allocUnsafe=function(t){return l(t)},a.allocUnsafeSlow=function(t){return l(t)},a.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==a.prototype},a.compare=function(t,e){if(Q(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),Q(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(t)||!a.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;for(var r=t.length,n=e.length,o=0,i=Math.min(r,n);o<i;++o)if(t[o]!==e[o]){r=t[o],n=e[o];break}return r<n?-1:n<r?1:0},a.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return a.alloc(0);var r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var n=a.allocUnsafe(e),o=0;for(r=0;r<t.length;++r){var i=t[r];if(Q(i,Uint8Array))o+i.length>n.length?a.from(i).copy(n,o):Uint8Array.prototype.set.call(n,i,o);else{if(!a.isBuffer(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(n,o)}o+=i.length}return n},a.byteLength=g,a.prototype._isBuffer=!0,a.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)m(this,e,e+1);return this},a.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)m(this,e,e+3),m(this,e+1,e+2);return this},a.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)m(this,e,e+7),m(this,e+1,e+6),m(this,e+2,e+5),m(this,e+3,e+4);return this},a.prototype.toString=function(){var t=this.length;return 0===t?"":0===arguments.length?U(this,0,t):d.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(t){if(!a.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===a.compare(this,t)},a.prototype.inspect=function(){var t="",r=e.IS;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},i&&(a.prototype[i]=a.prototype.inspect),a.prototype.compare=function(t,e,r,n,o){if(Q(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0),u=Math.min(i,s),f=this.slice(n,o),h=t.slice(e,r),l=0;l<u;++l)if(f[l]!==h[l]){i=f[l],s=h[l];break}return i<s?-1:s<i?1:0},a.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},a.prototype.indexOf=function(t,e,r){return w(this,t,e,r,!0)},a.prototype.lastIndexOf=function(t,e,r){return w(this,t,e,r,!1)},a.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return b(this,t,e,r);case"utf8":case"utf-8":return E(this,t,e,r);case"ascii":case"latin1":case"binary":return A(this,t,e,r);case"base64":return T(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var M=4096;function O(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;o<r;++o)n+=String.fromCharCode(127&t[o]);return n}function L(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;o<r;++o)n+=String.fromCharCode(t[o]);return n}function N(t,e,r){var n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);for(var o="",i=e;i<r;++i)o+=Y[t[i]];return o}function S(t,e,r){for(var n=t.slice(e,r),o="",i=0;i<n.length-1;i+=2)o+=String.fromCharCode(n[i]+256*n[i+1]);return o}function I(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function P(t,e,r,n,o,i){if(!a.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<i)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function k(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function R(t,e,r,n,i){return e=+e,r>>>=0,i||k(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function C(t,e,r,n,i){return e=+e,r>>>=0,i||k(t,0,r,8),o.write(t,e,r,n,52,8),r+8}a.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);var n=this.subarray(t,e);return Object.setPrototypeOf(n,a.prototype),n},a.prototype.readUintLE=a.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||I(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return n},a.prototype.readUintBE=a.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||I(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},a.prototype.readUint8=a.prototype.readUInt8=function(t,e){return t>>>=0,e||I(t,1,this.length),this[t]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(t,e){return t>>>=0,e||I(t,2,this.length),this[t]|this[t+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(t,e){return t>>>=0,e||I(t,2,this.length),this[t]<<8|this[t+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(t,e){return t>>>=0,e||I(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(t,e){return t>>>=0,e||I(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},a.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||I(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return n>=(o*=128)&&(n-=Math.pow(2,8*e)),n},a.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||I(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},a.prototype.readInt8=function(t,e){return t>>>=0,e||I(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},a.prototype.readInt16LE=function(t,e){t>>>=0,e||I(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt16BE=function(t,e){t>>>=0,e||I(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt32LE=function(t,e){return t>>>=0,e||I(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},a.prototype.readInt32BE=function(t,e){return t>>>=0,e||I(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},a.prototype.readFloatLE=function(t,e){return t>>>=0,e||I(t,4,this.length),o.read(this,t,!0,23,4)},a.prototype.readFloatBE=function(t,e){return t>>>=0,e||I(t,4,this.length),o.read(this,t,!1,23,4)},a.prototype.readDoubleLE=function(t,e){return t>>>=0,e||I(t,8,this.length),o.read(this,t,!0,52,8)},a.prototype.readDoubleBE=function(t,e){return t>>>=0,e||I(t,8,this.length),o.read(this,t,!1,52,8)},a.prototype.writeUintLE=a.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||P(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i<r&&(o*=256);)this[e+i]=t/o&255;return e+r},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||P(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},a.prototype.writeUint8=a.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||P(this,t,e,1,255,0),this[e]=255&t,e+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||P(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||P(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||P(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||P(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},a.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);P(this,t,e,r,o-1,-o)}var i=0,s=1,u=0;for(this[e]=255&t;++i<r&&(s*=256);)t<0&&0===u&&0!==this[e+i-1]&&(u=1),this[e+i]=(t/s|0)-u&255;return e+r},a.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);P(this,t,e,r,o-1,-o)}var i=r-1,s=1,u=0;for(this[e+i]=255&t;--i>=0&&(s*=256);)t<0&&0===u&&0!==this[e+i+1]&&(u=1),this[e+i]=(t/s|0)-u&255;return e+r},a.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||P(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},a.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||P(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},a.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||P(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},a.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||P(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},a.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||P(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},a.prototype.writeFloatLE=function(t,e,r){return R(this,t,e,!0,r)},a.prototype.writeFloatBE=function(t,e,r){return R(this,t,e,!1,r)},a.prototype.writeDoubleLE=function(t,e,r){return C(this,t,e,!0,r)},a.prototype.writeDoubleBE=function(t,e,r){return C(this,t,e,!1,r)},a.prototype.copy=function(t,e,r,n){if(!a.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);var o=n-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,n):Uint8Array.prototype.set.call(t,this.subarray(r,n),e),o},a.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!a.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var o=t.charCodeAt(0);("utf8"===n&&o<128||"latin1"===n)&&(t=o)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;var i;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i<r;++i)this[i]=t;else{var s=a.isBuffer(t)?t:a.from(t,n),u=s.length;if(0===u)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<r-e;++i)this[i+e]=s[i%u]}return this};var j=/[^+/0-9A-Za-z-_]/g;function D(t,e){var r;e=e||1/0;for(var n=t.length,o=null,i=[],s=0;s<n;++s){if((r=t.charCodeAt(s))>55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function q(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(j,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function F(t,e,r,n){for(var o=0;o<n&&!(o+r>=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function Q(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function _(t){return t!=t}var Y=function(){for(var t="0123456789abcdef",e=new Array(256),r=0;r<16;++r)for(var n=16*r,o=0;o<16;++o)e[n+o]=t[r]+t[o];return e}()},526:(t,e)=>{"use strict";e.byteLength=function(t){var e=u(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,i=u(t),s=i[0],a=i[1],f=new o(function(t,e,r){return 3*(e+r)/4-r}(0,s,a)),h=0,l=a>0?s-4:s;for(r=0;r<l;r+=4)e=n[t.charCodeAt(r)]<<18|n[t.charCodeAt(r+1)]<<12|n[t.charCodeAt(r+2)]<<6|n[t.charCodeAt(r+3)],f[h++]=e>>16&255,f[h++]=e>>8&255,f[h++]=255&e;return 2===a&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,f[h++]=255&e),1===a&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,f[h++]=e>>8&255,f[h++]=255&e),f},e.fromByteArray=function(t){for(var e,n=t.length,o=n%3,i=[],s=16383,u=0,f=n-o;u<f;u+=s)i.push(a(t,u,u+s>f?f:u+s));return 1===o?(e=t[n-1],i.push(r[e>>2]+r[e<<4&63]+"==")):2===o&&(e=(t[n-2]<<8)+t[n-1],i.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"=")),i.join("")};for(var r=[],n=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0;s<64;++s)r[s]=i[s],n[i.charCodeAt(s)]=s;function u(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function a(t,e,n){for(var o,i,s=[],u=e;u<n;u+=3)o=(t[u]<<16&16711680)+(t[u+1]<<8&65280)+(255&t[u+2]),s.push(r[(i=o)>>18&63]+r[i>>12&63]+r[i>>6&63]+r[63&i]);return s.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63}},e={};function r(n){var o=e[n];if(void 0!==o)return o.exports;var i=e[n]={exports:{}};return t[n](i,i.exports,r),i.exports}r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};(()=>{"use strict";async function t(t,e,r){const n=[];t.replace(e,((t,...e)=>(n.push(r(t,...e)),t)));const o=await Promise.all(n);return t.replace(e,(()=>o.shift()))}r.r(n),r.d(n,{TinyLevelUp:()=>e,TinyPromiseQueue:()=>T,asyncReplace:()=>t,checkObj:()=>d,cloneObjTypeOrder:()=>p,countObj:()=>m,extendObjType:()=>l,formatCustomTimer:()=>s,formatDayTimer:()=>a,formatTimer:()=>u,getAge:()=>b,getSimplePerc:()=>v,getTimeDuration:()=>i,objType:()=>g,reorderObjTypeOrder:()=>c,ruleOfThree:()=>w,shuffleArray:()=>o,toTitleCase:()=>E,toTitleCaseLowerFirst:()=>A});const e=class{constructor(t,e){this.giveExp=t,this.expLevel=e}expValidator(t){let e=0;const r=this.expLevel*t.level;return t.exp>=r&&(t.level++,e=t.exp-r,t.exp=0,e>0)?this.give(t,e,"extra"):t.exp<1&&t.level>1&&(t.level--,e=Math.abs(t.exp),t.exp=this.expLevel*t.level,e>0)?this.remove(t,e,"extra"):t}getTotalExp(t){let e=0;for(let r=1;r<=t.level;r++)e+=this.expLevel*r;return e+=t.exp,e}expGenerator(t=1){return Math.floor(Math.random()*this.giveExp)+1*t}progress(t){return this.expLevel*t.level}getProgress(t){return this.expLevel*t.level}set(t,e){return t.exp=e,this.expValidator(t),t.totalExp=this.getTotalExp(t),t}give(t,e=0,r="add",n=1){return"add"===r?t.exp+=this.expGenerator(n)+e:"extra"===r&&(t.exp+=e),this.expValidator(t),t.totalExp=this.getTotalExp(t),t}remove(t,e=0,r="add",n=1){return"add"===r?t.exp-=this.expGenerator(n)+e:"extra"===r&&(t.exp-=e),this.expValidator(t),t.totalExp=this.getTotalExp(t),t}};function o(t){let e,r=t.length;for(;0!==r;)e=Math.floor(Math.random()*r),r--,[t[r],t[e]]=[t[e],t[r]];return t}function i(t=new Date,e="asSeconds",r=null){if(t instanceof Date){const n=r instanceof Date?r:new Date,o=t.getTime()-n.getTime();switch(e){case"asMilliseconds":return o;case"asSeconds":default:return o/1e3;case"asMinutes":return o/6e4;case"asHours":return o/36e5;case"asDays":return o/864e5}}return null}function s(t,e="seconds",r="{time}"){t=Math.max(0,Math.floor(t));const n=["seconds","minutes","hours","days","months","years"].indexOf(e),o=n>=5,i=n>=4,s=n>=3,u=n>=2,a=n>=1,f=n>=0,h={years:o?0:NaN,months:i?0:NaN,days:s?0:NaN,hours:u?0:NaN,minutes:a?0:NaN,seconds:f?0:NaN,total:NaN};let l=t;if(o||i||s){const t=new Date(1980,0,1),e=new Date(t.getTime()+1e3*l),r=new Date(t);if(o)for(;new Date(r.getFullYear()+1,r.getMonth(),r.getDate()).getTime()<=e.getTime();)r.setFullYear(r.getFullYear()+1),h.years++;if(i)for(;new Date(r.getFullYear(),r.getMonth()+1,r.getDate()).getTime()<=e.getTime();)r.setMonth(r.getMonth()+1),h.months++;if(s)for(;new Date(r.getFullYear(),r.getMonth(),r.getDate()+1).getTime()<=e.getTime();)r.setDate(r.getDate()+1),h.days++;l=Math.floor((e.getTime()-r.getTime())/1e3)}u&&(h.hours=Math.floor(l/3600),l%=3600),a&&(h.minutes=Math.floor(l/60),l%=60),f&&(h.seconds=l);const c={seconds:f?t:NaN,minutes:a?t/60:NaN,hours:u?t/3600:NaN,days:s?t/86400:NaN,months:i?12*h.years+h.months+(h.days||0)/30:NaN,years:o?h.years+(h.months||0)/12+(h.days||0)/365:NaN};h.total=+(c[e]||0).toFixed(2).replace(/\.00$/,"");const p=t=>{const e="string"==typeof t?parseInt(t):t;return Number.isNaN(e)?"NaN":String(e).padStart(2,"0")},y=[u?p(h.hours):null,a?p(h.minutes):null,f?p(h.seconds):null].filter((t=>null!==t)).join(":");return r.replace(/\{years\}/g,String(h.years)).replace(/\{months\}/g,String(h.months)).replace(/\{days\}/g,String(h.days)).replace(/\{hours\}/g,p(h.hours)).replace(/\{minutes\}/g,p(h.minutes)).replace(/\{seconds\}/g,p(h.seconds)).replace(/\{time\}/g,y).replace(/\{total\}/g,String(h.total)).trim()}function u(t){return s(t,"hours","{hours}:{minutes}:{seconds}")}function a(t){return s(t,"days","{days}d {hours}:{minutes}:{seconds}")}var f=r(287);const h={items:{undefined:t=>void 0===t,null:t=>null===t,boolean:t=>"boolean"==typeof t,number:t=>"number"==typeof t&&!isNaN(t),bigint:t=>"bigint"==typeof t,string:t=>"string"==typeof t,symbol:t=>"symbol"==typeof t,function:t=>"function"==typeof t,array:t=>Array.isArray(t),date:t=>t instanceof Date,regexp:t=>t instanceof RegExp,map:t=>t instanceof Map,set:t=>t instanceof Set,weakmap:t=>t instanceof WeakMap,weakset:t=>t instanceof WeakSet,promise:t=>t instanceof Promise,buffer:t=>void 0!==f.hp&&f.hp.isBuffer(t),file:t=>"undefined"!=typeof File&&t instanceof File,htmlelement:t=>"undefined"!=typeof HTMLElement&&t instanceof HTMLElement,object:t=>"object"==typeof t&&null!==t},order:["undefined","null","boolean","number","bigint","string","symbol","function","array","buffer","file","date","regexp","map","set","weakmap","weakset","promise","htmlelement","object"]};function l(t,e){const r=[];for(const[n,o]of Object.entries(t))if(!h.items.hasOwnProperty(n)){h.items[n]=o;let t="number"==typeof e?e:-1;if(-1===t){const e=h.order.indexOf("object");t=e>-1?e:h.order.length}t=Math.min(Math.max(0,t),h.order.length),h.order.splice(t,0,n),r.push(n)}return r}function c(t){const e=[...h.order];return!!t.every((t=>e.includes(t)))&&(h.order=t.slice(),!0)}function p(){return[...h.order]}const y=t=>{if(null===t)return"null";for(const e of h.order)if("function"!=typeof h.items[e]||h.items[e](t))return e;return"unknown"};function g(t,e){if(void 0===t)return null;const r=y(t);return"string"==typeof e?r===e.toLowerCase():r}function d(t){const e={valid:null,type:null};for(const r of h.order)if("function"==typeof h.items[r]){const n=h.items[r](t);if(n){e.valid=n,e.type=r;break}}return e}function m(t){return Array.isArray(t)?t.length:g(t,"object")?Object.keys(t).length:0}function w(t,e,r,n=!1){return n?Number(t*e)/r:Number(r*e)/t}function v(t,e){return t*(e/100)}function b(t=0,e=null){if(null!=t&&0!==t){const r=new Date(t);if(Number.isNaN(r.getTime()))return null;const n=e instanceof Date?e:new Date;let o=n.getFullYear()-r.getFullYear();const i=n.getMonth(),s=r.getMonth(),u=n.getDate(),a=r.getDate();return(i<s||i===s&&u<a)&&o--,Math.abs(o)}return null}function E(t){return t.replace(/\w\S*/g,(t=>t.charAt(0).toUpperCase()+t.substr(1).toLowerCase()))}function A(t){const e=t.replace(/\w\S*/g,(t=>t.charAt(0).toUpperCase()+t.substr(1).toLowerCase()));return e.charAt(0).toLowerCase()+e.slice(1)}const T=class{#t=[];#e=!1;#r={};#n=new Set;isRunning(){return this.#e}async#o(t){if(t&&"function"==typeof t.task&&"function"==typeof t.resolve&&"function"==typeof t.reject){const{task:e,resolve:r,reject:n,delay:o,id:i}=t;try{if(i&&this.#n.has(i))return n(new Error("The function was canceled on TinyPromiseQueue.")),this.#n.delete(i),this.#e=!1,void this.#i();o&&i&&await new Promise((t=>{const e=setTimeout((()=>{delete this.#r[i],t(null)}),o);this.#r[i]=e})),r(await e())}catch(t){n(t)}finally{this.#e=!1,this.#i()}}}async#s(){const t=[];for(;this.#t.length&&"POINT_MARKER"===this.#t[0]?.marker;)t.push(this.#t.shift());if(0===t.length)return this.#e=!1,void this.#i();await Promise.all(t.map((({task:t,resolve:e,reject:r,id:n})=>new Promise((async o=>{if(n&&this.#n.has(n))return this.#n.delete(n),r(new Error("The function was canceled on TinyPromiseQueue.")),void o(!0);await t().then(e).catch(r),o(!0)}))))),this.#e=!1,this.#i()}async#i(){if(!this.#e&&0!==this.#t.length)if(this.#e=!0,"string"!=typeof this.#t[0]?.marker||"POINT_MARKER"!==this.#t[0]?.marker){const t=this.#t.shift();this.#o(t)}else this.#s()}getIndexById(t){return this.#t.findIndex((e=>e.id===t))}getQueuedIds(){return this.#t.map(((t,e)=>({index:e,id:t.id}))).filter((t=>"string"==typeof t.id))}reorderQueue(t,e){if("number"!=typeof t||"number"!=typeof e||t<0||e<0||t>=this.#t.length||e>=this.#t.length)return;const[r]=this.#t.splice(t,1);this.#t.splice(e,0,r)}async enqueuePoint(t,e){return this.#e?new Promise(((r,n)=>{this.#t.push({marker:"POINT_MARKER",task:t,resolve:r,reject:n,id:e}),this.#i()})):t()}enqueue(t,e,r){return new Promise(((n,o)=>{this.#t.push({task:t,resolve:n,reject:o,id:r,delay:e}),this.#i()}))}cancelTask(t){if(!t)return!1;let e=!1;t in this.#r&&(clearTimeout(this.#r[t]),delete this.#r[t],e=!0);const r=this.getIndexById(t);if(-1!==r){const[t]=this.#t.splice(r,1);t?.reject?.(new Error("The function was canceled on TinyPromiseQueue.")),e=!0}return e&&this.#n.add(t),e}}})(),window.TinyEssentials=n})();
@@ -45,6 +45,7 @@ class TinyPromiseQueue {
45
45
  * @property {(value: any) => any} resolve - The resolve function from the Promise.
46
46
  * @property {(reason?: any) => any} reject - The reject function from the Promise.
47
47
  * @property {string|undefined} [id] - Optional identifier for the task.
48
+ * @property {string|null|undefined} [marker] - Optional marker for the task.
48
49
  * @property {number|null|undefined} [delay] - Optional delay (in ms) before the task is executed.
49
50
  */
50
51
 
@@ -66,15 +67,13 @@ class TinyPromiseQueue {
66
67
  }
67
68
 
68
69
  /**
69
- * Processes the next task in the queue if not already running.
70
- * Ensures tasks are executed in order, one at a time.
70
+ * Processes the a normal task.
71
+ *
72
+ * @param {QueuedTask} data
71
73
  *
72
74
  * @returns {Promise<void>}
73
75
  */
74
- async #processQueue() {
75
- if (this.#running || this.#queue.length === 0) return;
76
- this.#running = true;
77
- const data = this.#queue.shift();
76
+ async #normalProcessQueue(data) {
78
77
  if (
79
78
  data &&
80
79
  typeof data.task === 'function' &&
@@ -83,6 +82,14 @@ class TinyPromiseQueue {
83
82
  ) {
84
83
  const { task, resolve, reject, delay, id } = data;
85
84
  try {
85
+ if (id && this.#blacklist.has(id)) {
86
+ reject(new Error('The function was canceled on TinyPromiseQueue.'));
87
+ this.#blacklist.delete(id);
88
+ this.#running = false;
89
+ this.#processQueue();
90
+ return;
91
+ }
92
+
86
93
  if (delay && id) {
87
94
  await new Promise((resolveDelay) => {
88
95
  const timeoutId = setTimeout(() => {
@@ -93,14 +100,6 @@ class TinyPromiseQueue {
93
100
  });
94
101
  }
95
102
 
96
- if (id && this.#blacklist.has(id)) {
97
- reject(new Error('The function was canceled on TinyPromiseQueue.'));
98
- this.#blacklist.delete(id);
99
- this.#running = false;
100
- this.#processQueue();
101
- return;
102
- }
103
-
104
103
  const result = await task();
105
104
  resolve(result);
106
105
  } catch (error) {
@@ -112,6 +111,61 @@ class TinyPromiseQueue {
112
111
  }
113
112
  }
114
113
 
114
+ /**
115
+ * Processes a group task.
116
+ *
117
+ * @returns {Promise<void>}
118
+ */
119
+ async #groupProcessQueue() {
120
+ /** @type {Array<QueuedTask>} */
121
+ const grouped = [];
122
+ while (this.#queue.length && this.#queue[0]?.marker === 'POINT_MARKER') {
123
+ // @ts-ignore
124
+ grouped.push(this.#queue.shift());
125
+ }
126
+
127
+ if (grouped.length === 0) {
128
+ this.#running = false;
129
+ this.#processQueue();
130
+ return;
131
+ }
132
+
133
+ await Promise.all(
134
+ grouped.map(
135
+ ({ task, resolve, reject, id }) =>
136
+ new Promise(async (pResolve) => {
137
+ if (id && this.#blacklist.has(id)) {
138
+ this.#blacklist.delete(id);
139
+ reject(new Error('The function was canceled on TinyPromiseQueue.'));
140
+ pResolve(true);
141
+ return;
142
+ }
143
+ await task().then(resolve).catch(reject);
144
+ pResolve(true);
145
+ }),
146
+ ),
147
+ );
148
+
149
+ this.#running = false;
150
+ this.#processQueue();
151
+ }
152
+
153
+ /**
154
+ * Processes the next task in the queue if not already running.
155
+ * Ensures tasks are executed in order, one at a time.
156
+ *
157
+ * @returns {Promise<void>}
158
+ */
159
+ async #processQueue() {
160
+ if (this.#running || this.#queue.length === 0) return;
161
+ this.#running = true;
162
+ if (typeof this.#queue[0]?.marker !== 'string' || this.#queue[0]?.marker !== 'POINT_MARKER') {
163
+ const data = this.#queue.shift();
164
+ // @ts-ignore
165
+ this.#normalProcessQueue(data);
166
+ } else this.#groupProcessQueue();
167
+ }
168
+
115
169
  /**
116
170
  * Returns the index of a task by its ID.
117
171
  *
@@ -154,6 +208,22 @@ class TinyPromiseQueue {
154
208
  this.#queue.splice(toIndex, 0, item);
155
209
  }
156
210
 
211
+ /**
212
+ * Inserts a point in the queue where subsequent tasks will be grouped and executed together in a Promise.all.
213
+ * If the queue is currently empty, behaves like a regular promise.
214
+ *
215
+ * @param {(...args: any[]) => Promise<any>|Promise<any>} task A function that returns a Promise.
216
+ * @param {string} [id] Optional ID to identify the task in the queue.
217
+ * @returns {Promise<any>} A Promise that resolves or rejects with the result of the task once it's processed.
218
+ */
219
+ async enqueuePoint(task, id) {
220
+ if (!this.#running) return task();
221
+ return new Promise((resolve, reject) => {
222
+ this.#queue.push({ marker: 'POINT_MARKER', task, resolve, reject, id });
223
+ this.#processQueue();
224
+ });
225
+ }
226
+
157
227
  /**
158
228
  * Adds a new async task to the queue and ensures it runs in order after previous tasks.
159
229
  * Optionally, a delay can be added before the task is executed.
@@ -192,7 +262,8 @@ class TinyPromiseQueue {
192
262
 
193
263
  const index = this.getIndexById(id);
194
264
  if (index !== -1) {
195
- this.#queue.splice(index, 1);
265
+ const [removed] = this.#queue.splice(index, 1);
266
+ removed?.reject?.(new Error('The function was canceled on TinyPromiseQueue.'));
196
267
  cancelled = true;
197
268
  }
198
269
 
@@ -1 +1 @@
1
- (()=>{"use strict";var e={d:(t,i)=>{for(var s in i)e.o(i,s)&&!e.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:i[s]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};e.d(t,{TinyPromiseQueue:()=>i});const i=class{#e=[];#t=!1;#i={};#s=new Set;isRunning(){return this.#t}async#u(){if(this.#t||0===this.#e.length)return;this.#t=!0;const e=this.#e.shift();if(e&&"function"==typeof e.task&&"function"==typeof e.resolve&&"function"==typeof e.reject){const{task:t,resolve:i,reject:s,delay:u,id:n}=e;try{if(u&&n&&await new Promise((e=>{const t=setTimeout((()=>{delete this.#i[n],e(null)}),u);this.#i[n]=t})),n&&this.#s.has(n))return s(new Error("The function was canceled on TinyPromiseQueue.")),this.#s.delete(n),this.#t=!1,void this.#u();i(await t())}catch(e){s(e)}finally{this.#t=!1,this.#u()}}}getIndexById(e){return this.#e.findIndex((t=>t.id===e))}getQueuedIds(){return this.#e.map(((e,t)=>({index:t,id:e.id}))).filter((e=>"string"==typeof e.id))}reorderQueue(e,t){if("number"!=typeof e||"number"!=typeof t||e<0||t<0||e>=this.#e.length||t>=this.#e.length)return;const[i]=this.#e.splice(e,1);this.#e.splice(t,0,i)}enqueue(e,t,i){return new Promise(((s,u)=>{this.#e.push({task:e,resolve:s,reject:u,id:i,delay:t}),this.#u()}))}cancelTask(e){if(!e)return!1;let t=!1;e in this.#i&&(clearTimeout(this.#i[e]),delete this.#i[e],t=!0);const i=this.getIndexById(e);return-1!==i&&(this.#e.splice(i,1),t=!0),t&&this.#s.add(e),t}};window.TinyPromiseQueue=t.TinyPromiseQueue})();
1
+ (()=>{"use strict";var e={d:(t,s)=>{for(var i in s)e.o(s,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:s[i]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};e.d(t,{TinyPromiseQueue:()=>s});const s=class{#e=[];#t=!1;#s={};#i=new Set;isRunning(){return this.#t}async#u(e){if(e&&"function"==typeof e.task&&"function"==typeof e.resolve&&"function"==typeof e.reject){const{task:t,resolve:s,reject:i,delay:u,id:n}=e;try{if(n&&this.#i.has(n))return i(new Error("The function was canceled on TinyPromiseQueue.")),this.#i.delete(n),this.#t=!1,void this.#n();u&&n&&await new Promise((e=>{const t=setTimeout((()=>{delete this.#s[n],e(null)}),u);this.#s[n]=t})),s(await t())}catch(e){i(e)}finally{this.#t=!1,this.#n()}}}async#r(){const e=[];for(;this.#e.length&&"POINT_MARKER"===this.#e[0]?.marker;)e.push(this.#e.shift());if(0===e.length)return this.#t=!1,void this.#n();await Promise.all(e.map((({task:e,resolve:t,reject:s,id:i})=>new Promise((async u=>{if(i&&this.#i.has(i))return this.#i.delete(i),s(new Error("The function was canceled on TinyPromiseQueue.")),void u(!0);await e().then(t).catch(s),u(!0)}))))),this.#t=!1,this.#n()}async#n(){if(!this.#t&&0!==this.#e.length)if(this.#t=!0,"string"!=typeof this.#e[0]?.marker||"POINT_MARKER"!==this.#e[0]?.marker){const e=this.#e.shift();this.#u(e)}else this.#r()}getIndexById(e){return this.#e.findIndex((t=>t.id===e))}getQueuedIds(){return this.#e.map(((e,t)=>({index:t,id:e.id}))).filter((e=>"string"==typeof e.id))}reorderQueue(e,t){if("number"!=typeof e||"number"!=typeof t||e<0||t<0||e>=this.#e.length||t>=this.#e.length)return;const[s]=this.#e.splice(e,1);this.#e.splice(t,0,s)}async enqueuePoint(e,t){return this.#t?new Promise(((s,i)=>{this.#e.push({marker:"POINT_MARKER",task:e,resolve:s,reject:i,id:t}),this.#n()})):e()}enqueue(e,t,s){return new Promise(((i,u)=>{this.#e.push({task:e,resolve:i,reject:u,id:s,delay:t}),this.#n()}))}cancelTask(e){if(!e)return!1;let t=!1;e in this.#s&&(clearTimeout(this.#s[e]),delete this.#s[e],t=!0);const s=this.getIndexById(e);if(-1!==s){const[e]=this.#e.splice(s,1);e?.reject?.(new Error("The function was canceled on TinyPromiseQueue.")),t=!0}return t&&this.#i.add(e),t}};window.TinyPromiseQueue=t.TinyPromiseQueue})();
@@ -15,6 +15,7 @@ class TinyPromiseQueue {
15
15
  * @property {(value: any) => any} resolve - The resolve function from the Promise.
16
16
  * @property {(reason?: any) => any} reject - The reject function from the Promise.
17
17
  * @property {string|undefined} [id] - Optional identifier for the task.
18
+ * @property {string|null|undefined} [marker] - Optional marker for the task.
18
19
  * @property {number|null|undefined} [delay] - Optional delay (in ms) before the task is executed.
19
20
  */
20
21
 
@@ -36,15 +37,13 @@ class TinyPromiseQueue {
36
37
  }
37
38
 
38
39
  /**
39
- * Processes the next task in the queue if not already running.
40
- * Ensures tasks are executed in order, one at a time.
40
+ * Processes the a normal task.
41
+ *
42
+ * @param {QueuedTask} data
41
43
  *
42
44
  * @returns {Promise<void>}
43
45
  */
44
- async #processQueue() {
45
- if (this.#running || this.#queue.length === 0) return;
46
- this.#running = true;
47
- const data = this.#queue.shift();
46
+ async #normalProcessQueue(data) {
48
47
  if (
49
48
  data &&
50
49
  typeof data.task === 'function' &&
@@ -53,6 +52,14 @@ class TinyPromiseQueue {
53
52
  ) {
54
53
  const { task, resolve, reject, delay, id } = data;
55
54
  try {
55
+ if (id && this.#blacklist.has(id)) {
56
+ reject(new Error('The function was canceled on TinyPromiseQueue.'));
57
+ this.#blacklist.delete(id);
58
+ this.#running = false;
59
+ this.#processQueue();
60
+ return;
61
+ }
62
+
56
63
  if (delay && id) {
57
64
  await new Promise((resolveDelay) => {
58
65
  const timeoutId = setTimeout(() => {
@@ -63,14 +70,6 @@ class TinyPromiseQueue {
63
70
  });
64
71
  }
65
72
 
66
- if (id && this.#blacklist.has(id)) {
67
- reject(new Error('The function was canceled on TinyPromiseQueue.'));
68
- this.#blacklist.delete(id);
69
- this.#running = false;
70
- this.#processQueue();
71
- return;
72
- }
73
-
74
73
  const result = await task();
75
74
  resolve(result);
76
75
  } catch (error) {
@@ -82,6 +81,61 @@ class TinyPromiseQueue {
82
81
  }
83
82
  }
84
83
 
84
+ /**
85
+ * Processes a group task.
86
+ *
87
+ * @returns {Promise<void>}
88
+ */
89
+ async #groupProcessQueue() {
90
+ /** @type {Array<QueuedTask>} */
91
+ const grouped = [];
92
+ while (this.#queue.length && this.#queue[0]?.marker === 'POINT_MARKER') {
93
+ // @ts-ignore
94
+ grouped.push(this.#queue.shift());
95
+ }
96
+
97
+ if (grouped.length === 0) {
98
+ this.#running = false;
99
+ this.#processQueue();
100
+ return;
101
+ }
102
+
103
+ await Promise.all(
104
+ grouped.map(
105
+ ({ task, resolve, reject, id }) =>
106
+ new Promise(async (pResolve) => {
107
+ if (id && this.#blacklist.has(id)) {
108
+ this.#blacklist.delete(id);
109
+ reject(new Error('The function was canceled on TinyPromiseQueue.'));
110
+ pResolve(true);
111
+ return;
112
+ }
113
+ await task().then(resolve).catch(reject);
114
+ pResolve(true);
115
+ }),
116
+ ),
117
+ );
118
+
119
+ this.#running = false;
120
+ this.#processQueue();
121
+ }
122
+
123
+ /**
124
+ * Processes the next task in the queue if not already running.
125
+ * Ensures tasks are executed in order, one at a time.
126
+ *
127
+ * @returns {Promise<void>}
128
+ */
129
+ async #processQueue() {
130
+ if (this.#running || this.#queue.length === 0) return;
131
+ this.#running = true;
132
+ if (typeof this.#queue[0]?.marker !== 'string' || this.#queue[0]?.marker !== 'POINT_MARKER') {
133
+ const data = this.#queue.shift();
134
+ // @ts-ignore
135
+ this.#normalProcessQueue(data);
136
+ } else this.#groupProcessQueue();
137
+ }
138
+
85
139
  /**
86
140
  * Returns the index of a task by its ID.
87
141
  *
@@ -124,6 +178,22 @@ class TinyPromiseQueue {
124
178
  this.#queue.splice(toIndex, 0, item);
125
179
  }
126
180
 
181
+ /**
182
+ * Inserts a point in the queue where subsequent tasks will be grouped and executed together in a Promise.all.
183
+ * If the queue is currently empty, behaves like a regular promise.
184
+ *
185
+ * @param {(...args: any[]) => Promise<any>|Promise<any>} task A function that returns a Promise.
186
+ * @param {string} [id] Optional ID to identify the task in the queue.
187
+ * @returns {Promise<any>} A Promise that resolves or rejects with the result of the task once it's processed.
188
+ */
189
+ async enqueuePoint(task, id) {
190
+ if (!this.#running) return task();
191
+ return new Promise((resolve, reject) => {
192
+ this.#queue.push({ marker: 'POINT_MARKER', task, resolve, reject, id });
193
+ this.#processQueue();
194
+ });
195
+ }
196
+
127
197
  /**
128
198
  * Adds a new async task to the queue and ensures it runs in order after previous tasks.
129
199
  * Optionally, a delay can be added before the task is executed.
@@ -162,7 +232,8 @@ class TinyPromiseQueue {
162
232
 
163
233
  const index = this.getIndexById(id);
164
234
  if (index !== -1) {
165
- this.#queue.splice(index, 1);
235
+ const [removed] = this.#queue.splice(index, 1);
236
+ removed?.reject?.(new Error('The function was canceled on TinyPromiseQueue.'));
166
237
  cancelled = true;
167
238
  }
168
239
 
@@ -37,6 +37,15 @@ declare class TinyPromiseQueue {
37
37
  * @param {number} toIndex The index where the task should be placed.
38
38
  */
39
39
  reorderQueue(fromIndex: number, toIndex: number): void;
40
+ /**
41
+ * Inserts a point in the queue where subsequent tasks will be grouped and executed together in a Promise.all.
42
+ * If the queue is currently empty, behaves like a regular promise.
43
+ *
44
+ * @param {(...args: any[]) => Promise<any>|Promise<any>} task A function that returns a Promise.
45
+ * @param {string} [id] Optional ID to identify the task in the queue.
46
+ * @returns {Promise<any>} A Promise that resolves or rejects with the result of the task once it's processed.
47
+ */
48
+ enqueuePoint(task: (...args: any[]) => Promise<any> | Promise<any>, id?: string): Promise<any>;
40
49
  /**
41
50
  * Adds a new async task to the queue and ensures it runs in order after previous tasks.
42
51
  * Optionally, a delay can be added before the task is executed.
@@ -13,6 +13,7 @@ class TinyPromiseQueue {
13
13
  * @property {(value: any) => any} resolve - The resolve function from the Promise.
14
14
  * @property {(reason?: any) => any} reject - The reject function from the Promise.
15
15
  * @property {string|undefined} [id] - Optional identifier for the task.
16
+ * @property {string|null|undefined} [marker] - Optional marker for the task.
16
17
  * @property {number|null|undefined} [delay] - Optional delay (in ms) before the task is executed.
17
18
  */
18
19
  /** @type {Array<QueuedTask>} */
@@ -31,22 +32,26 @@ class TinyPromiseQueue {
31
32
  return this.#running;
32
33
  }
33
34
  /**
34
- * Processes the next task in the queue if not already running.
35
- * Ensures tasks are executed in order, one at a time.
35
+ * Processes the a normal task.
36
+ *
37
+ * @param {QueuedTask} data
36
38
  *
37
39
  * @returns {Promise<void>}
38
40
  */
39
- async #processQueue() {
40
- if (this.#running || this.#queue.length === 0)
41
- return;
42
- this.#running = true;
43
- const data = this.#queue.shift();
41
+ async #normalProcessQueue(data) {
44
42
  if (data &&
45
43
  typeof data.task === 'function' &&
46
44
  typeof data.resolve === 'function' &&
47
45
  typeof data.reject === 'function') {
48
46
  const { task, resolve, reject, delay, id } = data;
49
47
  try {
48
+ if (id && this.#blacklist.has(id)) {
49
+ reject(new Error('The function was canceled on TinyPromiseQueue.'));
50
+ this.#blacklist.delete(id);
51
+ this.#running = false;
52
+ this.#processQueue();
53
+ return;
54
+ }
50
55
  if (delay && id) {
51
56
  await new Promise((resolveDelay) => {
52
57
  const timeoutId = setTimeout(() => {
@@ -56,13 +61,6 @@ class TinyPromiseQueue {
56
61
  this.#timeouts[id] = timeoutId;
57
62
  });
58
63
  }
59
- if (id && this.#blacklist.has(id)) {
60
- reject(new Error('The function was canceled on TinyPromiseQueue.'));
61
- this.#blacklist.delete(id);
62
- this.#running = false;
63
- this.#processQueue();
64
- return;
65
- }
66
64
  const result = await task();
67
65
  resolve(result);
68
66
  }
@@ -75,6 +73,54 @@ class TinyPromiseQueue {
75
73
  }
76
74
  }
77
75
  }
76
+ /**
77
+ * Processes a group task.
78
+ *
79
+ * @returns {Promise<void>}
80
+ */
81
+ async #groupProcessQueue() {
82
+ /** @type {Array<QueuedTask>} */
83
+ const grouped = [];
84
+ while (this.#queue.length && this.#queue[0]?.marker === 'POINT_MARKER') {
85
+ // @ts-ignore
86
+ grouped.push(this.#queue.shift());
87
+ }
88
+ if (grouped.length === 0) {
89
+ this.#running = false;
90
+ this.#processQueue();
91
+ return;
92
+ }
93
+ await Promise.all(grouped.map(({ task, resolve, reject, id }) => new Promise(async (pResolve) => {
94
+ if (id && this.#blacklist.has(id)) {
95
+ this.#blacklist.delete(id);
96
+ reject(new Error('The function was canceled on TinyPromiseQueue.'));
97
+ pResolve(true);
98
+ return;
99
+ }
100
+ await task().then(resolve).catch(reject);
101
+ pResolve(true);
102
+ })));
103
+ this.#running = false;
104
+ this.#processQueue();
105
+ }
106
+ /**
107
+ * Processes the next task in the queue if not already running.
108
+ * Ensures tasks are executed in order, one at a time.
109
+ *
110
+ * @returns {Promise<void>}
111
+ */
112
+ async #processQueue() {
113
+ if (this.#running || this.#queue.length === 0)
114
+ return;
115
+ this.#running = true;
116
+ if (typeof this.#queue[0]?.marker !== 'string' || this.#queue[0]?.marker !== 'POINT_MARKER') {
117
+ const data = this.#queue.shift();
118
+ // @ts-ignore
119
+ this.#normalProcessQueue(data);
120
+ }
121
+ else
122
+ this.#groupProcessQueue();
123
+ }
78
124
  /**
79
125
  * Returns the index of a task by its ID.
80
126
  *
@@ -112,6 +158,22 @@ class TinyPromiseQueue {
112
158
  const [item] = this.#queue.splice(fromIndex, 1);
113
159
  this.#queue.splice(toIndex, 0, item);
114
160
  }
161
+ /**
162
+ * Inserts a point in the queue where subsequent tasks will be grouped and executed together in a Promise.all.
163
+ * If the queue is currently empty, behaves like a regular promise.
164
+ *
165
+ * @param {(...args: any[]) => Promise<any>|Promise<any>} task A function that returns a Promise.
166
+ * @param {string} [id] Optional ID to identify the task in the queue.
167
+ * @returns {Promise<any>} A Promise that resolves or rejects with the result of the task once it's processed.
168
+ */
169
+ async enqueuePoint(task, id) {
170
+ if (!this.#running)
171
+ return task();
172
+ return new Promise((resolve, reject) => {
173
+ this.#queue.push({ marker: 'POINT_MARKER', task, resolve, reject, id });
174
+ this.#processQueue();
175
+ });
176
+ }
115
177
  /**
116
178
  * Adds a new async task to the queue and ensures it runs in order after previous tasks.
117
179
  * Optionally, a delay can be added before the task is executed.
@@ -148,7 +210,8 @@ class TinyPromiseQueue {
148
210
  }
149
211
  const index = this.getIndexById(id);
150
212
  if (index !== -1) {
151
- this.#queue.splice(index, 1);
213
+ const [removed] = this.#queue.splice(index, 1);
214
+ removed?.reject?.(new Error('The function was canceled on TinyPromiseQueue.'));
152
215
  cancelled = true;
153
216
  }
154
217
  if (cancelled)
@@ -22,6 +22,8 @@ Returns whether the queue is currently processing a task.
22
22
  #### Returns:
23
23
  - `boolean`: `true` if the queue is processing a task, otherwise `false`.
24
24
 
25
+ ---
26
+
25
27
  ### `getIndexById(id)` 🔍
26
28
 
27
29
  Returns the index of a task in the queue by its ID.
@@ -32,6 +34,8 @@ Returns the index of a task in the queue by its ID.
32
34
  #### Returns:
33
35
  - `number`: The index of the task in the queue, or `-1` if not found.
34
36
 
37
+ ---
38
+
35
39
  ### `getQueuedIds()` 📋
36
40
 
37
41
  Returns a list of IDs for all tasks currently in the queue.
@@ -39,6 +43,8 @@ Returns a list of IDs for all tasks currently in the queue.
39
43
  #### Returns:
40
44
  - `Array<{ index: number, id: string }>`: An array of task IDs and their corresponding indices.
41
45
 
46
+ ---
47
+
42
48
  ### `reorderQueue(fromIndex, toIndex)` 🔄
43
49
 
44
50
  Reorders a task in the queue from one index to another.
@@ -50,6 +56,8 @@ Reorders a task in the queue from one index to another.
50
56
  #### Returns:
51
57
  - `void`: This method does not return anything.
52
58
 
59
+ ---
60
+
53
61
  ### `enqueue(task, delay, id)` ⏳
54
62
 
55
63
  Adds a new async task to the queue and ensures it runs in order after previous tasks. Optionally, a delay can be added before the task is executed.
@@ -65,6 +73,26 @@ If the task is canceled before execution, it will be rejected with the message:
65
73
  #### Returns:
66
74
  - `Promise<any>`: A promise that resolves or rejects with the result of the task once it's processed.
67
75
 
76
+ ---
77
+
78
+ ### `enqueuePoint(task, id)` 🪢
79
+
80
+ Adds an async task to a parallel group in the queue. All tasks added with `enqueuePoint` before the next `enqueue` will be executed **simultaneously**, but only after all previous tasks in the queue have completed.
81
+
82
+ These grouped tasks share a "concurrent checkpoint" and will run using `Promise.all`. Each task resolves or rejects independently.
83
+
84
+ If a task is canceled before execution, it will be rejected with the message:
85
+ **"The function was canceled on TinyPromiseQueue."**
86
+
87
+ #### Parameters:
88
+ - `task` (`Function`): A function that returns a `Promise` to be executed sequentially.
89
+ - `id` (`string`): Optional ID to identify the task in the queue.
90
+
91
+ #### Returns:
92
+ - `Promise<any>`: A promise that resolves or rejects with the result of the task once it's processed.
93
+
94
+ ---
95
+
68
96
  ### `cancelTask(id)` ❌
69
97
 
70
98
  Cancels a scheduled delay and removes the task from the queue. Adds the ID to a blacklist so the task is skipped if already being processed.
@@ -113,6 +141,73 @@ setTimeout(() => {
113
141
  }, 60);
114
142
  ```
115
143
 
144
+ ```js
145
+ import { TinyPromiseQueue } from './TinyPromiseQueue';
146
+
147
+ const queue = new TinyPromiseQueue();
148
+ await new Promise((resolve) => {
149
+
150
+ // Task generator with color-coded logs
151
+ function createTask(name, duration = 500) {
152
+ return () =>
153
+ new Promise((resolve) => {
154
+ console.log(`\x1b[34m[STARTED]\x1b[0m \x1b[36m${name}\x1b[0m`);
155
+ setTimeout(() => {
156
+ console.log(`\x1b[32m[FINISHED]\x1b[0m \x1b[36m${name}\x1b[0m`);
157
+ resolve(name);
158
+ }, duration);
159
+ });
160
+ }
161
+
162
+ // Function to simulate a parallel group of enqueues
163
+ const parallelEnqueueGroup = (groupName, delayStart = 0) => {
164
+ const count = Math.floor(Math.random() * (15 - 1 + 1) + 1);
165
+ for (let i = 1; i <= count; i++) {
166
+ const taskName = `${groupName}-${i}`;
167
+ queue.enqueue(createTask(taskName, 300 + i * 50), delayStart, taskName);
168
+ }
169
+ };
170
+
171
+ // Main enqueue block
172
+ queue.enqueue(createTask('Init-1', 400), 50, 'init-1');
173
+ queue.enqueue(createTask('Init-2', 400), 0, 'init-2');
174
+
175
+ // Simulate enqueues from other contexts "in parallel"
176
+ parallelEnqueueGroup('Alpha', 80); // Starts after 80ms
177
+ parallelEnqueueGroup('Beta', 120); // Starts after 120ms
178
+ parallelEnqueueGroup('Gamma', 250); // Starts after 250ms
179
+ parallelEnqueueGroup('Delta', 180); // Starts after 180ms
180
+ parallelEnqueueGroup('Epsilon', 300); // Starts after 300ms
181
+ parallelEnqueueGroup('Zeta', 160); // Starts after 160ms
182
+ parallelEnqueueGroup('Eta', 90); // Starts after 90ms
183
+ parallelEnqueueGroup('Theta', 220); // Starts after 220ms
184
+ parallelEnqueueGroup('Iota', 140); // Starts after 140ms
185
+ parallelEnqueueGroup('Kappa', 400); // Starts after 400ms
186
+ parallelEnqueueGroup('Lambda', 190); // Starts after 190ms
187
+ parallelEnqueueGroup('Mu', 260); // Starts after 260ms
188
+ parallelEnqueueGroup('Nu', 110); // Starts after 110ms
189
+ parallelEnqueueGroup('Xi', 330); // Starts after 330ms
190
+ parallelEnqueueGroup('Omicron', 170); // Starts after 170ms
191
+ parallelEnqueueGroup('Pi', 280); // Starts after 280ms
192
+ parallelEnqueueGroup('Rho', 70); // Starts after 70ms
193
+ parallelEnqueueGroup('Sigma', 360); // Starts after 360ms
194
+ parallelEnqueueGroup('Tau', 130); // Starts after 130ms
195
+ parallelEnqueueGroup('Upsilon', 240); // Starts after 240ms
196
+ parallelEnqueueGroup('Phi', 310); // Starts after 310ms
197
+ parallelEnqueueGroup('Chi', 100); // Starts after 100ms
198
+ parallelEnqueueGroup('Psi', 200); // Starts after 200ms
199
+ parallelEnqueueGroup('Omega', 50); // Starts after 50ms
200
+
201
+ // Final task to confirm everything executed
202
+ setTimeout(() => {
203
+ queue.enqueue(createTask('Finalizer', 500), 0, 'finalizer').then(() => {
204
+ console.log('\x1b[35m[QUEUE COMPLETE]\x1b[0m All tasks have been processed.');
205
+ resolve();
206
+ });
207
+ }, 250);
208
+ });
209
+ ```
210
+
116
211
  ### Explanation 🧩:
117
212
  1. **Task Creation**: Tasks are created with a name and an optional duration (in ms). The task logs its start and finish times 🕰️.
118
213
  2. **Task Execution**: Tasks are enqueued one at a time, ensuring they run in the order they were added 🔁.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tiny-essentials",
3
- "version": "1.5.1",
3
+ "version": "1.6.0",
4
4
  "description": "Collection of small, essential scripts designed to be used across various projects. These simple utilities are crafted for speed, ease of use, and versatility.",
5
5
  "scripts": {
6
6
  "test": "npm run test:mjs && npm run test:cjs && npm run test:js",