@develia/commons 0.3.29 → 0.3.31

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.
@@ -24,7 +24,7 @@
24
24
  * @template TKey The type of the key.
25
25
  * @template TValue The type of the value.
26
26
  */
27
- class Pair {
27
+ class KeyValuePair {
28
28
  get value() {
29
29
  return this._value;
30
30
  }
@@ -102,6 +102,54 @@
102
102
  function isFunction(value) {
103
103
  return typeof value === 'function';
104
104
  }
105
+ /**
106
+ * Compares two objects or arrays to check if they have the same fields and values,
107
+ * or the same elements if they are arrays.
108
+ *
109
+ * @param {any} a - The first object or array.
110
+ * @param {any} b - The second object or array.
111
+ * @return {boolean} - Returns true if the objects/arrays are equal, otherwise false.
112
+ */
113
+ function deepEqual(a, b) {
114
+ if (a === b) {
115
+ // If both values are strictly equal, return true
116
+ return true;
117
+ }
118
+ // If either value is null or their types differ, return false
119
+ if (a === null || b === null || typeof a !== typeof b) {
120
+ return false;
121
+ }
122
+ // Check if both values are arrays
123
+ if (Array.isArray(a) && Array.isArray(b)) {
124
+ // Compare lengths and elements recursively
125
+ if (a.length !== b.length) {
126
+ return false;
127
+ }
128
+ for (let i = 0; i < a.length; i++) {
129
+ if (!deepEqual(a[i], b[i])) {
130
+ return false;
131
+ }
132
+ }
133
+ return true;
134
+ }
135
+ // Check if both values are objects
136
+ if (typeof a === "object" && typeof b === "object") {
137
+ const keysA = Object.keys(a);
138
+ const keysB = Object.keys(b);
139
+ // Compare the keys length and check if all keys/values match
140
+ if (keysA.length !== keysB.length) {
141
+ return false;
142
+ }
143
+ for (const key of keysA) {
144
+ if (!keysB.includes(key) || !deepEqual(a[key], b[key])) {
145
+ return false;
146
+ }
147
+ }
148
+ return true;
149
+ }
150
+ // For all other data types (e.g., numbers, strings, booleans), use strict equality
151
+ return false;
152
+ }
105
153
  /**
106
154
  * Pauses the execution of an asynchronous function for a specified duration.
107
155
  *
@@ -211,12 +259,12 @@
211
259
  * Converts an object into an array of key-value pairs.
212
260
  *
213
261
  * @param {Record<string, any>} obj - The object to convert.
214
- * @return {Pair<string, any>[]} - The array of key-value pairs.
262
+ * @return {KeyValuePair<string, any>[]} - The array of key-value pairs.
215
263
  */
216
264
  function toPairs(obj) {
217
265
  let output = [];
218
266
  for (const key in obj) {
219
- output.push(new Pair(key, obj[key]));
267
+ output.push(new KeyValuePair(key, obj[key]));
220
268
  }
221
269
  return output;
222
270
  }
@@ -1193,6 +1241,7 @@
1193
1241
  * Represents a class for manipulating an array of items.
1194
1242
  *
1195
1243
  * @template T - The type of items in the array.
1244
+ * @deprecated
1196
1245
  */
1197
1246
  class ArrayManipulator {
1198
1247
  constructor(array) {
@@ -1321,61 +1370,91 @@
1321
1370
  }
1322
1371
 
1323
1372
  class AsyncPoolExecutor {
1324
- constructor(maxConcurrency) {
1373
+ get maxConcurrency() {
1374
+ return this._maxConcurrency;
1375
+ }
1376
+ set maxConcurrency(value) {
1377
+ this._maxConcurrency = value;
1378
+ }
1379
+ /**
1380
+ * @param {number} maxConcurrency - The maximum number of concurrent tasks allowed.
1381
+ * @param {number} [checkInterval=50] - The interval, in milliseconds, to check for capacity to run new tasks. Defaults to 50 ms.
1382
+ */
1383
+ constructor(maxConcurrency, checkInterval = 50) {
1325
1384
  this._taskQueue = [];
1326
- this._activeTasks = 0;
1327
1385
  this._maxConcurrency = maxConcurrency;
1386
+ this._checkIntervalMs = checkInterval;
1387
+ this._activeTasks = 0;
1328
1388
  }
1329
1389
  /**
1330
1390
  * Submits a deferred task to a queue for asynchronous execution and returns a Promise resolving to its result.
1331
1391
  * @template T
1332
- * @param {Deferred<T>} task - The deferred task to be executed asynchronously.
1333
- * @return {Promise<T>} A Promise that resolves with the result of the executed task, or rejects if an error occurs during execution.
1392
+ * @param {Supplier<T>} task - The deferred task to be executed asynchronously.
1334
1393
  */
1335
1394
  submit(task) {
1336
- return new Promise((resolve, reject) => {
1337
- this._taskQueue.push(async () => {
1338
- try {
1339
- this._activeTasks++;
1340
- resolve(await promisify(task));
1341
- }
1342
- catch (error) {
1343
- reject(error);
1395
+ this._taskQueue.push(task);
1396
+ if (this._proccess != null)
1397
+ return;
1398
+ this._proccess = setTimeout(async () => {
1399
+ while (this._taskQueue.length > 0) {
1400
+ while (this._activeTasks >= this._maxConcurrency) {
1401
+ await delay(this._checkIntervalMs);
1344
1402
  }
1345
- finally {
1346
- this._activeTasks--;
1347
- this._runNext(); // Intenta ejecutar la siguiente tarea
1403
+ const task = this._taskQueue.shift();
1404
+ if (task) {
1405
+ this._activeTasks++;
1406
+ setTimeout(async () => {
1407
+ try {
1408
+ await task();
1409
+ }
1410
+ finally {
1411
+ this._activeTasks--;
1412
+ }
1413
+ });
1348
1414
  }
1349
- });
1350
- this._runNext();
1351
- });
1352
- }
1353
- _runNext() {
1354
- while (this._activeTasks < this._maxConcurrency && this._taskQueue.length > 0) {
1355
- const nextTask = this._taskQueue.shift();
1356
- nextTask && nextTask();
1357
- }
1415
+ }
1416
+ this._proccess = null;
1417
+ }, 0);
1358
1418
  }
1359
1419
  /**
1360
- * Gracefully shuts down the system by waiting for all queued and active tasks to complete.
1361
- * The method ensures that no tasks remain in the queue and no tasks are actively running
1362
- * before resolving the promise.
1420
+ * Waits until all tasks (both queued and active) are completed.
1421
+ * This method resolves only when there are no pending tasks.
1363
1422
  *
1364
- * @return {Promise<void>} A promise that resolves when the shutdown process is complete.
1423
+ * @return {Promise<void>} A promise that resolves when all tasks are complete.
1365
1424
  */
1366
1425
  async shutdown() {
1367
1426
  while (this._taskQueue.length > 0 || this._activeTasks > 0) {
1368
- await new Promise((resolve) => setTimeout(resolve, 50));
1427
+ await delay(this._checkIntervalMs);
1369
1428
  }
1370
1429
  }
1371
1430
  }
1372
1431
 
1432
+ /**
1433
+ * Removes all given values from the provided array and returns the number of removed elements.
1434
+ * The operation mutates the original array.
1435
+ * @template T
1436
+ * @param {Array<T>} array - The array to modify by removing specified items.
1437
+ * @param {...T} items - The values to remove from the array.
1438
+ * @return {number} The number of elements removed from the array.
1439
+ */
1440
+ function pull(array, ...items) {
1441
+ let output = 0;
1442
+ for (const item of items) {
1443
+ const index = array.indexOf(item);
1444
+ if (index !== -1) {
1445
+ array.splice(index, 1);
1446
+ output++;
1447
+ }
1448
+ }
1449
+ return output;
1450
+ }
1451
+
1373
1452
  exports.ArrayManipulator = ArrayManipulator;
1374
1453
  exports.AsyncPoolExecutor = AsyncPoolExecutor;
1375
1454
  exports.CacheDictionary = CacheDictionary;
1376
1455
  exports.From = From;
1456
+ exports.KeyValuePair = KeyValuePair;
1377
1457
  exports.Lazy = Lazy;
1378
- exports.Pair = Pair;
1379
1458
  exports.TimeSpan = TimeSpan;
1380
1459
  exports.Timer = Timer;
1381
1460
  exports.ajaxSubmission = ajaxSubmission;
@@ -1383,6 +1462,7 @@
1383
1462
  exports.array = array;
1384
1463
  exports.clamp = clamp;
1385
1464
  exports.deepClone = deepClone;
1465
+ exports.deepEqual = deepEqual;
1386
1466
  exports.delay = delay;
1387
1467
  exports.ensurePrefix = ensurePrefix;
1388
1468
  exports.ensureSuffix = ensureSuffix;
@@ -1407,6 +1487,7 @@
1407
1487
  exports.lerp = lerp;
1408
1488
  exports.objectToFormData = objectToFormData;
1409
1489
  exports.promisify = promisify;
1490
+ exports.pull = pull;
1410
1491
  exports.toPairs = toPairs;
1411
1492
 
1412
1493
  })(this.window = this.window || {});
@@ -1 +1 @@
1
- !function(t){"use strict";var e;t.Type=void 0,(e=t.Type||(t.Type={})).Undefined="undefined",e.Number="number",e.String="string",e.Boolean="boolean",e.Object="object",e.Function="function",e.Symbol="symbol",e.BigInt="bigint",e.Null="null";class r{get value(){return this._value}get key(){return this._key}constructor(t,e){this._key=t,this._value=e}}function n(t){return"function"==typeof t}async function i(t){const e="string"==typeof t?document.querySelector(t):t;if(!(e instanceof HTMLFormElement))throw new Error("Invalid element.");return await fetch(e.action,{method:e.method,body:new FormData(e)})}function s(t){let e=[];for(const n in t)e.push(new r(n,t[n]));return e}function o(t){return t instanceof Promise?t:n(t)?new Promise(((e,r)=>{try{e(t())}catch(t){r(t)}})):Promise.resolve(t)}function l(t,e,r=""){for(const n in t)if(t.hasOwnProperty(n)){const i=t[n];i instanceof Date?e.append(r?`${r}[${n}]`:n,i.toISOString()):i instanceof File?e.append(r?`${r}[${n}]`:n,i):"object"!=typeof i||Array.isArray(i)?Array.isArray(i)?i.forEach(((t,i)=>{const s=`${r?`${r}[${n}]`:n}[${i}]`;"object"!=typeof t||Array.isArray(t)?e.append(s,t):l(t,e,s)})):e.append(r?`${r}[${n}]`:n,i):l(i,e,r?`${r}[${n}]`:n)}return e}class a{static object(t){return new a((function(){return s(t)}))}static _shallowEqual(t,e){const r=Object.keys(t),n=Object.keys(e);if(r.length!==n.length)return!1;for(let n of r)if(t[n]!==e[n])return!1;return!0}constructor(t){this._fn=t}static fn(t){return new a(t)}collect(){const t=Array.from(this);return a.iterable(t)}static iterable(t){return a.fn((function*(){for(const e of t)yield e}))}map(t){const e=this;return a.fn((function*(){for(let r of e)yield t(r)}))}*[Symbol.iterator](){yield*this._fn()}all(t){for(let e of this._fn())if(!t(e))return!1;return!0}any(t=void 0){for(let e of this)if(null==t||t(e))return!0;return!1}get length(){return this.count()}count(t=void 0){let e=0;for(let r of this)(null==t||t(r))&&e++;return e}filter(t){const e=this;return a.fn((function*(){for(let r of e)t(r)&&(yield r)}))}contains(t){for(let e of this)if(e===t)return!0;return!1}first(t){if(t){for(let e of this)if(!t||t(e))return e}else for(let t of this)return t}append(t){const e=this;return a.fn((function*(){for(let t of e)yield t;yield t}))}prepend(t){const e=this;return a.fn((function*(){yield t;for(let t of e)yield t}))}at(t){let e=0;for(let r of this)if(e++===t)return r}last(t){let e;if(t)for(let r of this)t&&!t(r)||(e=r);else for(let t of this)e=t;return e}mapMany(t){const e=this;return a.fn((function*(){for(const r of e){const e=t(r);for(const t of e)yield t}}))}flatten(){const t=this;return a.fn((function*(){for(let e of t){let t=e;for(let e of t)yield e}}))}sum(t){let e=0;if(t)for(let r of this)e+=t(r);else for(let t of this)e+=t;return e}avg(t){let e=0,r=0;if(t)for(let n of this)e+=t(n),r++;else for(let t of this)e+=t,r++;return r>0?e/r:0}max(t){let e=-1/0;for(let r of this){let n=t(r);e=n>e?n:e}return e}min(t){let e=1/0;for(let r of this){let n=t(r);e=n<e?n:e}return e}maxBy(t){let e,r=-1/0;for(let n of this){let i=t(n);i>r&&(r=i,e=n)}return e}minBy(t){let e,r=1/0;for(let n of this){let i=t(n);i<r&&(r=i,e=n)}return e}orderBy(t){const e=Array.from(this._fn());return e.sort(((e,r)=>{const n=t(e),i=t(r);return n>i?1:n<i?-1:0})),a.iterable(e)}groupBy(t,e){e=null==e?a._shallowEqual:e;const r=this;return a.fn((function*(){const n=[];for(let i of r){const r=t(i);let s=!1;for(let[t,o]of n)if(e(r,t)){o.push(i),s=!0;break}s||n.push([r,[i]])}yield*n.map((([t,e])=>new u(t,e)))}))}head(t){const e=this;return a.fn((function*(){let r=0;for(let n of e){if(!(r++<t))return;yield n}}))}tail(t){const e=this;return a.fn((function*(){let r=[];for(let n of e)r.push(n),r.length>t&&r.shift();yield*r}))}forEach(t){for(let e of this)t(e)}toArray(){return Array.from(this)}instancesOf(t){return this.filter((e=>typeof e===t))}allInstanceOf(t){for(let e of this)if(!(e instanceof t))return!1;return!0}distinct(t){null==t&&(t=a._shallowEqual);const e=this;return a.fn((function*(){const r=[];for(let n of e)a.iterable(r).any((e=>t(e,n)))||(r.push(n),yield n)}))}insert(t,e){const r=this;return a.fn((function*(){let n=0,i=!1;for(let s of r)n===e&&(yield t,i=!0),yield s,n++;i||(yield t)}))}skip(t){const e=this;return a.fn((function*(){let r=0;for(let n of e)r>=t&&(yield n),r++}))}union(t){const e=this;return a.fn((function*(){yield*e,yield*t}))}innerJoin(t,e,r,n){const i=this;return a.fn((()=>{const s=new Map;for(let e of t)s.set(r(e),e);return Array.from(i).filter((t=>s.has(e(t)))).map((t=>n(t,s.get(e(t)))))}))}leftJoin(t,e,r,n){const i=this;return a.fn((()=>{const s=new Map;for(let e of t)s.set(r(e),e);return Array.from(i).map((t=>n(t,s.get(e(t)))))}))}leftGroupJoin(t,e,r,n){const i=this;return a.fn((()=>{const s=new Map;for(let e of t){const t=r(e);s.has(t)||s.set(t,[]),s.get(t).push(e)}return Array.from(i).map((t=>n(t,s.get(e(t))||[])))}))}rightGroupJoin(t,e,r,n){const i=this;return a.fn((()=>{const s=new Map;for(let t of i){const r=e(t);s.has(r)||s.set(r,[]),s.get(r).push(t)}return Array.from(t).map((t=>n(s.get(r(t))||[],t)))}))}rightJoin(t,e,r,n){const i=this;return a.fn((()=>{const s=new Map;for(let t of i)s.set(e(t),t);return Array.from(t).map((t=>n(s.get(r(t)),t)))}))}}class u extends a{get key(){return this._key}constructor(t,e){super((()=>e)),this._key=t}}class c{constructor(t){this.milliseconds=t}seconds(){return this.milliseconds/1e3}minutes(){return this.milliseconds/6e4}hours(){return this.milliseconds/36e5}days(){return this.milliseconds/864e5}weeks(){return this.milliseconds/6048e5}static fromMilliseconds(t){return new c(t)}static fromSeconds(t){return new c(1e3*t)}static fromMinutes(t){return new c(1e3*t*60)}static fromHours(t){return new c(1e3*t*60*60)}static fromDays(t){return new c(1e3*t*60*60*24)}static fromWeeks(t){return new c(1e3*t*60*60*24*7)}addMilliseconds(t){return new c(this.milliseconds+t)}addSeconds(t){return this.addMilliseconds(1e3*t)}addMinutes(t){return this.addMilliseconds(1e3*t*60)}addHours(t){return this.addMilliseconds(1e3*t*60*60)}addDays(t){return this.addMilliseconds(1e3*t*60*60*24)}addWeeks(t){return this.addMilliseconds(1e3*t*60*60*24*7)}subtractMilliseconds(t){return new c(this.milliseconds-t)}subtractSeconds(t){return this.subtractMilliseconds(1e3*t)}subtractMinutes(t){return this.subtractMilliseconds(1e3*t*60)}subtractHours(t){return this.subtractMilliseconds(1e3*t*60*60)}subtractDays(t){return this.subtractMilliseconds(1e3*t*60*60*24)}subtractWeeks(t){return this.subtractMilliseconds(1e3*t*60*60*24*7)}add(t){return new c(this.milliseconds+t.milliseconds)}subtract(t){return new c(this.milliseconds-t.milliseconds)}addTo(t){return new Date(t.getTime()+this.milliseconds)}subtractFrom(t){return new Date(t.getTime()-this.milliseconds)}static fromDifference(t,e){return new c(e.getTime()-t.getTime())}format(t="hh:mm:ss"){const e=t.toLowerCase(),r=e.includes("h"),n=e.includes("m");let i=0,s=0,o=Math.floor(this.milliseconds/1e3);r&&(i=Math.floor(o/3600),o-=3600*i),n&&(s=Math.floor(o/60),o-=60*s);const l=String(i).padStart(2,"0"),a=String(s).padStart(2,"0"),u=String(o).padStart(2,"0");return e.replace("hh",l).replace("h",i.toString()).replace("mm",a).replace("m",s.toString()).replace("ss",u).replace("s",o.toString())}eq(t){return this.milliseconds===t.milliseconds}le(t){return this.milliseconds<=t.milliseconds}lt(t){return this.milliseconds<t.milliseconds}ge(t){return this.milliseconds>=t.milliseconds}gt(t){return this.milliseconds>t.milliseconds}multiply(t){return new c(this.milliseconds*t)}divide(t){return new c(this.milliseconds/t)}abs(){return new c(Math.abs(this.milliseconds))}isInfinite(){return this.milliseconds===Number.POSITIVE_INFINITY||this.milliseconds===Number.NEGATIVE_INFINITY}isPositiveInfinite(){return this.milliseconds===Number.POSITIVE_INFINITY}isNegativeInfinite(){return this.milliseconds===Number.NEGATIVE_INFINITY}}c.INFINITE=new c(Number.POSITIVE_INFINITY),c.NEGATIVE_INFINITE=new c(Number.NEGATIVE_INFINITY);class f{constructor(t){this._array=t}[Symbol.iterator](){return this._array[Symbol.iterator]()}at(t,e=void 0){if(void 0===e)return this._array[t];this._array[t]=e}remove(t){const e=this._array.indexOf(t);return-1!==e&&this._array.splice(e,1),this}map(t){for(let e=0;e<this._array.length;e++)this._array[e]=t(this._array[e]);return this}filter(t){for(let e=0;e<this._array.length;e++)t(this._array[e])||(this._array.splice(e,1),e--);return this}head(t){return this._array.splice(t),this}slice(t,e=void 0){return this._array.splice(0,t),void 0!==e&&this._array.splice(e),this}mapMany(t){let e=0;for(;e<this._array.length;){let r=t(this._array[e]);Array.isArray(r)||(r=Array.from(r)),this._array.splice(e,1,...r),e+=r.length}return this}tail(t){const e=this._array.length-t;return this._array.splice(0,e),this}append(...t){return this._array.push(...t),this}prepend(...t){return this._array.unshift(...t),this}get array(){return this._array}}t.ArrayManipulator=f,t.AsyncPoolExecutor=class{constructor(t){this._taskQueue=[],this._activeTasks=0,this._maxConcurrency=t}submit(t){return new Promise(((e,r)=>{this._taskQueue.push((async()=>{try{this._activeTasks++,e(await o(t))}catch(t){r(t)}finally{this._activeTasks--,this._runNext()}})),this._runNext()}))}_runNext(){for(;this._activeTasks<this._maxConcurrency&&this._taskQueue.length>0;){const t=this._taskQueue.shift();t&&t()}}async shutdown(){for(;this._taskQueue.length>0||this._activeTasks>0;)await new Promise((t=>setTimeout(t,50)))}},t.CacheDictionary=class{constructor(t=null,e=null){this.fallback=t,this.cache={},this.defaultDuration=e,this.expiration={}}getExpiration(t){return this.expiration[t]}setExpiration(t,e){this.expiration[t]=e}setDuration(t,e){if(null===e)delete this.expiration[t];else{const r=new Date;r.setSeconds(r.getSeconds()+e),this.expiration[t]=r}}get(t){if(!this.cache.hasOwnProperty(t)){if(!this.fallback)return null;this.cache[t]=this.fallback(t),this.expiration[t]=this.calculateExpiration(this.defaultDuration)}return this.isExpired(t)?(this.remove(t),null):this.cache[t]}set(t,e,r=null){this.cache[t]=e,this.expiration[t]=this.calculateExpiration(r)}remove(t){delete this.cache[t],delete this.expiration[t]}isExpired(t){const e=this.expiration[t];return e instanceof Date&&e<new Date}calculateExpiration(t){if(null===t)return;const e=new Date;return e.setSeconds(e.getSeconds()+t),e}},t.From=a,t.Lazy=class{constructor(t){this._valueCreated=!1,this._value=null,this._factoryMethod=t}get valueCreated(){return this._valueCreated}get value(){return this._valueCreated||(this._value=this._factoryMethod(),this._valueCreated=!0),this._value}reset(){this._valueCreated=!1,this._value=null}},t.Pair=r,t.TimeSpan=c,t.Timer=class{constructor(t,e){this._callback=t,this._interval=e,this._intervalId=null}get running(){return null!==this._intervalId&&void 0!==this._intervalId}get interval(){return this._interval}set interval(t){t!=this._interval&&(this._interval=t,this.running&&this.restart())}get callback(){return this._callback}set callback(t){t!=this._callback&&(this._callback=t)}start(){null===this._intervalId&&(this._intervalId=setInterval((()=>{null!=this._callback&&this._callback()}),this._interval))}stop(){null!==this._intervalId&&(clearInterval(this._intervalId),this._intervalId=null)}restart(){this.stop(),this.start()}},t.ajaxSubmission=function(t,e=void 0,r=void 0){const n="string"==typeof t?document.querySelector(t):t;n instanceof HTMLFormElement&&n.addEventListener("submit",(async t=>{t.preventDefault();let s=i(n);s&&(e&&(s=s.then(e)),r&&s.catch(r))}))},t.ajaxSubmit=i,t.array=function(t){return new f(t)},t.clamp=function(t,e,r){return t<=e?e:t>=r?r:t},t.deepClone=function t(e){if(null===e||"object"!=typeof e)return e;if(Array.isArray(e)){const r=[];for(const n of e)r.push(t(n));return r}const r={};for(const n in e)e.hasOwnProperty(n)&&(r[n]=t(e[n]));return r},t.delay=async function(t){await new Promise((e=>setTimeout(e,t)))},t.ensurePrefix=function(t,e){return t.startsWith(e)?t:e+t},t.ensureSuffix=function(t,e){return t.endsWith(e)?t:t+e},t.format=function(t,...e){let r;return 1===e.length&&"object"==typeof e[0]?(e=e[0],r=/{(.+?)}/g):r=/{(\d+?)}/g,t.replace(r,((t,r)=>void 0!==e[r]?e[r]:""))},t.from=function(t){if(null==t)throw"Source is null.";if("function"==typeof t)return a.fn(t);if("function"==typeof t[Symbol.iterator])return a.iterable(t);if("object"==typeof t)return a.object(t);throw"Invalid source."},t.getType=function(e){return null===e?t.Type.Null:t.Type[typeof e]},t.isArray=function(t){return Array.isArray(t)},t.isBigInt=function(t){return"bigint"==typeof t},t.isBoolean=function(t){return"boolean"==typeof t},t.isDefined=function(t){return void 0!==t},t.isEmpty=function(t){return Array.isArray(t)&&0===t.length||"string"==typeof t&&""===t||null==t},t.isEmptyOrWhitespace=function(t){return Array.isArray(t)&&0===t.length||"string"==typeof t&&""===t.trim()||null==t},t.isFunction=n,t.isIterable=function(t){return"function"===t[Symbol.iterator]},t.isNull=function(t){return null===t},t.isNullOrUndefined=function(t){return null==t},t.isNumber=function(t){return"number"==typeof t},t.isObject=function(t){return null!=t&&"object"==typeof t&&!Array.isArray(t)},t.isString=function(t){return"string"==typeof t},t.isSymbol=function(t){return"symbol"==typeof t},t.isUndefined=function(t){return void 0===t},t.lerp=function(t,e,r,n,i){return n+(t-e)/(r-e)*(i-n)},t.objectToFormData=function(t){return l(t,new FormData)},t.promisify=o,t.toPairs=s}(this.window=this.window||{});
1
+ !function(t){"use strict";var e;t.Type=void 0,(e=t.Type||(t.Type={})).Undefined="undefined",e.Number="number",e.String="string",e.Boolean="boolean",e.Object="object",e.Function="function",e.Symbol="symbol",e.BigInt="bigint",e.Null="null";class r{get value(){return this._value}get key(){return this._key}constructor(t,e){this._key=t,this._value=e}}function n(t){return"function"==typeof t}async function i(t){await new Promise((e=>setTimeout(e,t)))}async function s(t){const e="string"==typeof t?document.querySelector(t):t;if(!(e instanceof HTMLFormElement))throw new Error("Invalid element.");return await fetch(e.action,{method:e.method,body:new FormData(e)})}function o(t){let e=[];for(const n in t)e.push(new r(n,t[n]));return e}function l(t,e,r=""){for(const n in t)if(t.hasOwnProperty(n)){const i=t[n];i instanceof Date?e.append(r?`${r}[${n}]`:n,i.toISOString()):i instanceof File?e.append(r?`${r}[${n}]`:n,i):"object"!=typeof i||Array.isArray(i)?Array.isArray(i)?i.forEach(((t,i)=>{const s=`${r?`${r}[${n}]`:n}[${i}]`;"object"!=typeof t||Array.isArray(t)?e.append(s,t):l(t,e,s)})):e.append(r?`${r}[${n}]`:n,i):l(i,e,r?`${r}[${n}]`:n)}return e}class a{static object(t){return new a((function(){return o(t)}))}static _shallowEqual(t,e){const r=Object.keys(t),n=Object.keys(e);if(r.length!==n.length)return!1;for(let n of r)if(t[n]!==e[n])return!1;return!0}constructor(t){this._fn=t}static fn(t){return new a(t)}collect(){const t=Array.from(this);return a.iterable(t)}static iterable(t){return a.fn((function*(){for(const e of t)yield e}))}map(t){const e=this;return a.fn((function*(){for(let r of e)yield t(r)}))}*[Symbol.iterator](){yield*this._fn()}all(t){for(let e of this._fn())if(!t(e))return!1;return!0}any(t=void 0){for(let e of this)if(null==t||t(e))return!0;return!1}get length(){return this.count()}count(t=void 0){let e=0;for(let r of this)(null==t||t(r))&&e++;return e}filter(t){const e=this;return a.fn((function*(){for(let r of e)t(r)&&(yield r)}))}contains(t){for(let e of this)if(e===t)return!0;return!1}first(t){if(t){for(let e of this)if(!t||t(e))return e}else for(let t of this)return t}append(t){const e=this;return a.fn((function*(){for(let t of e)yield t;yield t}))}prepend(t){const e=this;return a.fn((function*(){yield t;for(let t of e)yield t}))}at(t){let e=0;for(let r of this)if(e++===t)return r}last(t){let e;if(t)for(let r of this)t&&!t(r)||(e=r);else for(let t of this)e=t;return e}mapMany(t){const e=this;return a.fn((function*(){for(const r of e){const e=t(r);for(const t of e)yield t}}))}flatten(){const t=this;return a.fn((function*(){for(let e of t){let t=e;for(let e of t)yield e}}))}sum(t){let e=0;if(t)for(let r of this)e+=t(r);else for(let t of this)e+=t;return e}avg(t){let e=0,r=0;if(t)for(let n of this)e+=t(n),r++;else for(let t of this)e+=t,r++;return r>0?e/r:0}max(t){let e=-1/0;for(let r of this){let n=t(r);e=n>e?n:e}return e}min(t){let e=1/0;for(let r of this){let n=t(r);e=n<e?n:e}return e}maxBy(t){let e,r=-1/0;for(let n of this){let i=t(n);i>r&&(r=i,e=n)}return e}minBy(t){let e,r=1/0;for(let n of this){let i=t(n);i<r&&(r=i,e=n)}return e}orderBy(t){const e=Array.from(this._fn());return e.sort(((e,r)=>{const n=t(e),i=t(r);return n>i?1:n<i?-1:0})),a.iterable(e)}groupBy(t,e){e=null==e?a._shallowEqual:e;const r=this;return a.fn((function*(){const n=[];for(let i of r){const r=t(i);let s=!1;for(let[t,o]of n)if(e(r,t)){o.push(i),s=!0;break}s||n.push([r,[i]])}yield*n.map((([t,e])=>new u(t,e)))}))}head(t){const e=this;return a.fn((function*(){let r=0;for(let n of e){if(!(r++<t))return;yield n}}))}tail(t){const e=this;return a.fn((function*(){let r=[];for(let n of e)r.push(n),r.length>t&&r.shift();yield*r}))}forEach(t){for(let e of this)t(e)}toArray(){return Array.from(this)}instancesOf(t){return this.filter((e=>typeof e===t))}allInstanceOf(t){for(let e of this)if(!(e instanceof t))return!1;return!0}distinct(t){null==t&&(t=a._shallowEqual);const e=this;return a.fn((function*(){const r=[];for(let n of e)a.iterable(r).any((e=>t(e,n)))||(r.push(n),yield n)}))}insert(t,e){const r=this;return a.fn((function*(){let n=0,i=!1;for(let s of r)n===e&&(yield t,i=!0),yield s,n++;i||(yield t)}))}skip(t){const e=this;return a.fn((function*(){let r=0;for(let n of e)r>=t&&(yield n),r++}))}union(t){const e=this;return a.fn((function*(){yield*e,yield*t}))}innerJoin(t,e,r,n){const i=this;return a.fn((()=>{const s=new Map;for(let e of t)s.set(r(e),e);return Array.from(i).filter((t=>s.has(e(t)))).map((t=>n(t,s.get(e(t)))))}))}leftJoin(t,e,r,n){const i=this;return a.fn((()=>{const s=new Map;for(let e of t)s.set(r(e),e);return Array.from(i).map((t=>n(t,s.get(e(t)))))}))}leftGroupJoin(t,e,r,n){const i=this;return a.fn((()=>{const s=new Map;for(let e of t){const t=r(e);s.has(t)||s.set(t,[]),s.get(t).push(e)}return Array.from(i).map((t=>n(t,s.get(e(t))||[])))}))}rightGroupJoin(t,e,r,n){const i=this;return a.fn((()=>{const s=new Map;for(let t of i){const r=e(t);s.has(r)||s.set(r,[]),s.get(r).push(t)}return Array.from(t).map((t=>n(s.get(r(t))||[],t)))}))}rightJoin(t,e,r,n){const i=this;return a.fn((()=>{const s=new Map;for(let t of i)s.set(e(t),t);return Array.from(t).map((t=>n(s.get(r(t)),t)))}))}}class u extends a{get key(){return this._key}constructor(t,e){super((()=>e)),this._key=t}}class c{constructor(t){this.milliseconds=t}seconds(){return this.milliseconds/1e3}minutes(){return this.milliseconds/6e4}hours(){return this.milliseconds/36e5}days(){return this.milliseconds/864e5}weeks(){return this.milliseconds/6048e5}static fromMilliseconds(t){return new c(t)}static fromSeconds(t){return new c(1e3*t)}static fromMinutes(t){return new c(1e3*t*60)}static fromHours(t){return new c(1e3*t*60*60)}static fromDays(t){return new c(1e3*t*60*60*24)}static fromWeeks(t){return new c(1e3*t*60*60*24*7)}addMilliseconds(t){return new c(this.milliseconds+t)}addSeconds(t){return this.addMilliseconds(1e3*t)}addMinutes(t){return this.addMilliseconds(1e3*t*60)}addHours(t){return this.addMilliseconds(1e3*t*60*60)}addDays(t){return this.addMilliseconds(1e3*t*60*60*24)}addWeeks(t){return this.addMilliseconds(1e3*t*60*60*24*7)}subtractMilliseconds(t){return new c(this.milliseconds-t)}subtractSeconds(t){return this.subtractMilliseconds(1e3*t)}subtractMinutes(t){return this.subtractMilliseconds(1e3*t*60)}subtractHours(t){return this.subtractMilliseconds(1e3*t*60*60)}subtractDays(t){return this.subtractMilliseconds(1e3*t*60*60*24)}subtractWeeks(t){return this.subtractMilliseconds(1e3*t*60*60*24*7)}add(t){return new c(this.milliseconds+t.milliseconds)}subtract(t){return new c(this.milliseconds-t.milliseconds)}addTo(t){return new Date(t.getTime()+this.milliseconds)}subtractFrom(t){return new Date(t.getTime()-this.milliseconds)}static fromDifference(t,e){return new c(e.getTime()-t.getTime())}format(t="hh:mm:ss"){const e=t.toLowerCase(),r=e.includes("h"),n=e.includes("m");let i=0,s=0,o=Math.floor(this.milliseconds/1e3);r&&(i=Math.floor(o/3600),o-=3600*i),n&&(s=Math.floor(o/60),o-=60*s);const l=String(i).padStart(2,"0"),a=String(s).padStart(2,"0"),u=String(o).padStart(2,"0");return e.replace("hh",l).replace("h",i.toString()).replace("mm",a).replace("m",s.toString()).replace("ss",u).replace("s",o.toString())}eq(t){return this.milliseconds===t.milliseconds}le(t){return this.milliseconds<=t.milliseconds}lt(t){return this.milliseconds<t.milliseconds}ge(t){return this.milliseconds>=t.milliseconds}gt(t){return this.milliseconds>t.milliseconds}multiply(t){return new c(this.milliseconds*t)}divide(t){return new c(this.milliseconds/t)}abs(){return new c(Math.abs(this.milliseconds))}isInfinite(){return this.milliseconds===Number.POSITIVE_INFINITY||this.milliseconds===Number.NEGATIVE_INFINITY}isPositiveInfinite(){return this.milliseconds===Number.POSITIVE_INFINITY}isNegativeInfinite(){return this.milliseconds===Number.NEGATIVE_INFINITY}}c.INFINITE=new c(Number.POSITIVE_INFINITY),c.NEGATIVE_INFINITE=new c(Number.NEGATIVE_INFINITY);class f{constructor(t){this._array=t}[Symbol.iterator](){return this._array[Symbol.iterator]()}at(t,e=void 0){if(void 0===e)return this._array[t];this._array[t]=e}remove(t){const e=this._array.indexOf(t);return-1!==e&&this._array.splice(e,1),this}map(t){for(let e=0;e<this._array.length;e++)this._array[e]=t(this._array[e]);return this}filter(t){for(let e=0;e<this._array.length;e++)t(this._array[e])||(this._array.splice(e,1),e--);return this}head(t){return this._array.splice(t),this}slice(t,e=void 0){return this._array.splice(0,t),void 0!==e&&this._array.splice(e),this}mapMany(t){let e=0;for(;e<this._array.length;){let r=t(this._array[e]);Array.isArray(r)||(r=Array.from(r)),this._array.splice(e,1,...r),e+=r.length}return this}tail(t){const e=this._array.length-t;return this._array.splice(0,e),this}append(...t){return this._array.push(...t),this}prepend(...t){return this._array.unshift(...t),this}get array(){return this._array}}t.ArrayManipulator=f,t.AsyncPoolExecutor=class{get maxConcurrency(){return this._maxConcurrency}set maxConcurrency(t){this._maxConcurrency=t}constructor(t,e=50){this._taskQueue=[],this._maxConcurrency=t,this._checkIntervalMs=e,this._activeTasks=0}submit(t){this._taskQueue.push(t),null==this._proccess&&(this._proccess=setTimeout((async()=>{for(;this._taskQueue.length>0;){for(;this._activeTasks>=this._maxConcurrency;)await i(this._checkIntervalMs);const t=this._taskQueue.shift();t&&(this._activeTasks++,setTimeout((async()=>{try{await t()}finally{this._activeTasks--}})))}this._proccess=null}),0))}async shutdown(){for(;this._taskQueue.length>0||this._activeTasks>0;)await i(this._checkIntervalMs)}},t.CacheDictionary=class{constructor(t=null,e=null){this.fallback=t,this.cache={},this.defaultDuration=e,this.expiration={}}getExpiration(t){return this.expiration[t]}setExpiration(t,e){this.expiration[t]=e}setDuration(t,e){if(null===e)delete this.expiration[t];else{const r=new Date;r.setSeconds(r.getSeconds()+e),this.expiration[t]=r}}get(t){if(!this.cache.hasOwnProperty(t)){if(!this.fallback)return null;this.cache[t]=this.fallback(t),this.expiration[t]=this.calculateExpiration(this.defaultDuration)}return this.isExpired(t)?(this.remove(t),null):this.cache[t]}set(t,e,r=null){this.cache[t]=e,this.expiration[t]=this.calculateExpiration(r)}remove(t){delete this.cache[t],delete this.expiration[t]}isExpired(t){const e=this.expiration[t];return e instanceof Date&&e<new Date}calculateExpiration(t){if(null===t)return;const e=new Date;return e.setSeconds(e.getSeconds()+t),e}},t.From=a,t.KeyValuePair=r,t.Lazy=class{constructor(t){this._valueCreated=!1,this._value=null,this._factoryMethod=t}get valueCreated(){return this._valueCreated}get value(){return this._valueCreated||(this._value=this._factoryMethod(),this._valueCreated=!0),this._value}reset(){this._valueCreated=!1,this._value=null}},t.TimeSpan=c,t.Timer=class{constructor(t,e){this._callback=t,this._interval=e,this._intervalId=null}get running(){return null!==this._intervalId&&void 0!==this._intervalId}get interval(){return this._interval}set interval(t){t!=this._interval&&(this._interval=t,this.running&&this.restart())}get callback(){return this._callback}set callback(t){t!=this._callback&&(this._callback=t)}start(){null===this._intervalId&&(this._intervalId=setInterval((()=>{null!=this._callback&&this._callback()}),this._interval))}stop(){null!==this._intervalId&&(clearInterval(this._intervalId),this._intervalId=null)}restart(){this.stop(),this.start()}},t.ajaxSubmission=function(t,e=void 0,r=void 0){const n="string"==typeof t?document.querySelector(t):t;n instanceof HTMLFormElement&&n.addEventListener("submit",(async t=>{t.preventDefault();let i=s(n);i&&(e&&(i=i.then(e)),r&&i.catch(r))}))},t.ajaxSubmit=s,t.array=function(t){return new f(t)},t.clamp=function(t,e,r){return t<=e?e:t>=r?r:t},t.deepClone=function t(e){if(null===e||"object"!=typeof e)return e;if(Array.isArray(e)){const r=[];for(const n of e)r.push(t(n));return r}const r={};for(const n in e)e.hasOwnProperty(n)&&(r[n]=t(e[n]));return r},t.deepEqual=function t(e,r){if(e===r)return!0;if(null===e||null===r||typeof e!=typeof r)return!1;if(Array.isArray(e)&&Array.isArray(r)){if(e.length!==r.length)return!1;for(let n=0;n<e.length;n++)if(!t(e[n],r[n]))return!1;return!0}if("object"==typeof e&&"object"==typeof r){const n=Object.keys(e),i=Object.keys(r);if(n.length!==i.length)return!1;for(const s of n)if(!i.includes(s)||!t(e[s],r[s]))return!1;return!0}return!1},t.delay=i,t.ensurePrefix=function(t,e){return t.startsWith(e)?t:e+t},t.ensureSuffix=function(t,e){return t.endsWith(e)?t:t+e},t.format=function(t,...e){let r;return 1===e.length&&"object"==typeof e[0]?(e=e[0],r=/{(.+?)}/g):r=/{(\d+?)}/g,t.replace(r,((t,r)=>void 0!==e[r]?e[r]:""))},t.from=function(t){if(null==t)throw"Source is null.";if("function"==typeof t)return a.fn(t);if("function"==typeof t[Symbol.iterator])return a.iterable(t);if("object"==typeof t)return a.object(t);throw"Invalid source."},t.getType=function(e){return null===e?t.Type.Null:t.Type[typeof e]},t.isArray=function(t){return Array.isArray(t)},t.isBigInt=function(t){return"bigint"==typeof t},t.isBoolean=function(t){return"boolean"==typeof t},t.isDefined=function(t){return void 0!==t},t.isEmpty=function(t){return Array.isArray(t)&&0===t.length||"string"==typeof t&&""===t||null==t},t.isEmptyOrWhitespace=function(t){return Array.isArray(t)&&0===t.length||"string"==typeof t&&""===t.trim()||null==t},t.isFunction=n,t.isIterable=function(t){return"function"===t[Symbol.iterator]},t.isNull=function(t){return null===t},t.isNullOrUndefined=function(t){return null==t},t.isNumber=function(t){return"number"==typeof t},t.isObject=function(t){return null!=t&&"object"==typeof t&&!Array.isArray(t)},t.isString=function(t){return"string"==typeof t},t.isSymbol=function(t){return"symbol"==typeof t},t.isUndefined=function(t){return void 0===t},t.lerp=function(t,e,r,n,i){return n+(t-e)/(r-e)*(i-n)},t.objectToFormData=function(t){return l(t,new FormData)},t.promisify=function(t){return t instanceof Promise?t:n(t)?new Promise(((e,r)=>{try{e(t())}catch(t){r(t)}})):Promise.resolve(t)},t.pull=function(t,...e){let r=0;for(const n of e){const e=t.indexOf(n);-1!==e&&(t.splice(e,1),r++)}return r},t.toPairs=o}(this.window=this.window||{});
package/dist/index.cjs.js CHANGED
@@ -23,7 +23,7 @@ exports.Type = void 0;
23
23
  * @template TKey The type of the key.
24
24
  * @template TValue The type of the value.
25
25
  */
26
- class Pair {
26
+ class KeyValuePair {
27
27
  get value() {
28
28
  return this._value;
29
29
  }
@@ -101,6 +101,54 @@ function isArray(value) {
101
101
  function isFunction(value) {
102
102
  return typeof value === 'function';
103
103
  }
104
+ /**
105
+ * Compares two objects or arrays to check if they have the same fields and values,
106
+ * or the same elements if they are arrays.
107
+ *
108
+ * @param {any} a - The first object or array.
109
+ * @param {any} b - The second object or array.
110
+ * @return {boolean} - Returns true if the objects/arrays are equal, otherwise false.
111
+ */
112
+ function deepEqual(a, b) {
113
+ if (a === b) {
114
+ // If both values are strictly equal, return true
115
+ return true;
116
+ }
117
+ // If either value is null or their types differ, return false
118
+ if (a === null || b === null || typeof a !== typeof b) {
119
+ return false;
120
+ }
121
+ // Check if both values are arrays
122
+ if (Array.isArray(a) && Array.isArray(b)) {
123
+ // Compare lengths and elements recursively
124
+ if (a.length !== b.length) {
125
+ return false;
126
+ }
127
+ for (let i = 0; i < a.length; i++) {
128
+ if (!deepEqual(a[i], b[i])) {
129
+ return false;
130
+ }
131
+ }
132
+ return true;
133
+ }
134
+ // Check if both values are objects
135
+ if (typeof a === "object" && typeof b === "object") {
136
+ const keysA = Object.keys(a);
137
+ const keysB = Object.keys(b);
138
+ // Compare the keys length and check if all keys/values match
139
+ if (keysA.length !== keysB.length) {
140
+ return false;
141
+ }
142
+ for (const key of keysA) {
143
+ if (!keysB.includes(key) || !deepEqual(a[key], b[key])) {
144
+ return false;
145
+ }
146
+ }
147
+ return true;
148
+ }
149
+ // For all other data types (e.g., numbers, strings, booleans), use strict equality
150
+ return false;
151
+ }
104
152
  /**
105
153
  * Pauses the execution of an asynchronous function for a specified duration.
106
154
  *
@@ -210,12 +258,12 @@ async function ajaxSubmit(selectorOrElement) {
210
258
  * Converts an object into an array of key-value pairs.
211
259
  *
212
260
  * @param {Record<string, any>} obj - The object to convert.
213
- * @return {Pair<string, any>[]} - The array of key-value pairs.
261
+ * @return {KeyValuePair<string, any>[]} - The array of key-value pairs.
214
262
  */
215
263
  function toPairs(obj) {
216
264
  let output = [];
217
265
  for (const key in obj) {
218
- output.push(new Pair(key, obj[key]));
266
+ output.push(new KeyValuePair(key, obj[key]));
219
267
  }
220
268
  return output;
221
269
  }
@@ -1192,6 +1240,7 @@ class Lazy {
1192
1240
  * Represents a class for manipulating an array of items.
1193
1241
  *
1194
1242
  * @template T - The type of items in the array.
1243
+ * @deprecated
1195
1244
  */
1196
1245
  class ArrayManipulator {
1197
1246
  constructor(array) {
@@ -1320,61 +1369,91 @@ function array(array) {
1320
1369
  }
1321
1370
 
1322
1371
  class AsyncPoolExecutor {
1323
- constructor(maxConcurrency) {
1372
+ get maxConcurrency() {
1373
+ return this._maxConcurrency;
1374
+ }
1375
+ set maxConcurrency(value) {
1376
+ this._maxConcurrency = value;
1377
+ }
1378
+ /**
1379
+ * @param {number} maxConcurrency - The maximum number of concurrent tasks allowed.
1380
+ * @param {number} [checkInterval=50] - The interval, in milliseconds, to check for capacity to run new tasks. Defaults to 50 ms.
1381
+ */
1382
+ constructor(maxConcurrency, checkInterval = 50) {
1324
1383
  this._taskQueue = [];
1325
- this._activeTasks = 0;
1326
1384
  this._maxConcurrency = maxConcurrency;
1385
+ this._checkIntervalMs = checkInterval;
1386
+ this._activeTasks = 0;
1327
1387
  }
1328
1388
  /**
1329
1389
  * Submits a deferred task to a queue for asynchronous execution and returns a Promise resolving to its result.
1330
1390
  * @template T
1331
- * @param {Deferred<T>} task - The deferred task to be executed asynchronously.
1332
- * @return {Promise<T>} A Promise that resolves with the result of the executed task, or rejects if an error occurs during execution.
1391
+ * @param {Supplier<T>} task - The deferred task to be executed asynchronously.
1333
1392
  */
1334
1393
  submit(task) {
1335
- return new Promise((resolve, reject) => {
1336
- this._taskQueue.push(async () => {
1337
- try {
1338
- this._activeTasks++;
1339
- resolve(await promisify(task));
1340
- }
1341
- catch (error) {
1342
- reject(error);
1394
+ this._taskQueue.push(task);
1395
+ if (this._proccess != null)
1396
+ return;
1397
+ this._proccess = setTimeout(async () => {
1398
+ while (this._taskQueue.length > 0) {
1399
+ while (this._activeTasks >= this._maxConcurrency) {
1400
+ await delay(this._checkIntervalMs);
1343
1401
  }
1344
- finally {
1345
- this._activeTasks--;
1346
- this._runNext(); // Intenta ejecutar la siguiente tarea
1402
+ const task = this._taskQueue.shift();
1403
+ if (task) {
1404
+ this._activeTasks++;
1405
+ setTimeout(async () => {
1406
+ try {
1407
+ await task();
1408
+ }
1409
+ finally {
1410
+ this._activeTasks--;
1411
+ }
1412
+ });
1347
1413
  }
1348
- });
1349
- this._runNext();
1350
- });
1351
- }
1352
- _runNext() {
1353
- while (this._activeTasks < this._maxConcurrency && this._taskQueue.length > 0) {
1354
- const nextTask = this._taskQueue.shift();
1355
- nextTask && nextTask();
1356
- }
1414
+ }
1415
+ this._proccess = null;
1416
+ }, 0);
1357
1417
  }
1358
1418
  /**
1359
- * Gracefully shuts down the system by waiting for all queued and active tasks to complete.
1360
- * The method ensures that no tasks remain in the queue and no tasks are actively running
1361
- * before resolving the promise.
1419
+ * Waits until all tasks (both queued and active) are completed.
1420
+ * This method resolves only when there are no pending tasks.
1362
1421
  *
1363
- * @return {Promise<void>} A promise that resolves when the shutdown process is complete.
1422
+ * @return {Promise<void>} A promise that resolves when all tasks are complete.
1364
1423
  */
1365
1424
  async shutdown() {
1366
1425
  while (this._taskQueue.length > 0 || this._activeTasks > 0) {
1367
- await new Promise((resolve) => setTimeout(resolve, 50));
1426
+ await delay(this._checkIntervalMs);
1368
1427
  }
1369
1428
  }
1370
1429
  }
1371
1430
 
1431
+ /**
1432
+ * Removes all given values from the provided array and returns the number of removed elements.
1433
+ * The operation mutates the original array.
1434
+ * @template T
1435
+ * @param {Array<T>} array - The array to modify by removing specified items.
1436
+ * @param {...T} items - The values to remove from the array.
1437
+ * @return {number} The number of elements removed from the array.
1438
+ */
1439
+ function pull(array, ...items) {
1440
+ let output = 0;
1441
+ for (const item of items) {
1442
+ const index = array.indexOf(item);
1443
+ if (index !== -1) {
1444
+ array.splice(index, 1);
1445
+ output++;
1446
+ }
1447
+ }
1448
+ return output;
1449
+ }
1450
+
1372
1451
  exports.ArrayManipulator = ArrayManipulator;
1373
1452
  exports.AsyncPoolExecutor = AsyncPoolExecutor;
1374
1453
  exports.CacheDictionary = CacheDictionary;
1375
1454
  exports.From = From;
1455
+ exports.KeyValuePair = KeyValuePair;
1376
1456
  exports.Lazy = Lazy;
1377
- exports.Pair = Pair;
1378
1457
  exports.TimeSpan = TimeSpan;
1379
1458
  exports.Timer = Timer;
1380
1459
  exports.ajaxSubmission = ajaxSubmission;
@@ -1382,6 +1461,7 @@ exports.ajaxSubmit = ajaxSubmit;
1382
1461
  exports.array = array;
1383
1462
  exports.clamp = clamp;
1384
1463
  exports.deepClone = deepClone;
1464
+ exports.deepEqual = deepEqual;
1385
1465
  exports.delay = delay;
1386
1466
  exports.ensurePrefix = ensurePrefix;
1387
1467
  exports.ensureSuffix = ensureSuffix;
@@ -1406,5 +1486,6 @@ exports.isUndefined = isUndefined;
1406
1486
  exports.lerp = lerp;
1407
1487
  exports.objectToFormData = objectToFormData;
1408
1488
  exports.promisify = promisify;
1489
+ exports.pull = pull;
1409
1490
  exports.toPairs = toPairs;
1410
1491
  //# sourceMappingURL=index.cjs.js.map