@andrew_l/toolkit 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -180,6 +180,9 @@ const primitiveTypeofSet = Object.freeze(
180
180
  const isPrimitive = (value) => {
181
181
  return value === null || primitiveTypeofSet.has(typeof value);
182
182
  };
183
+ function isNode() {
184
+ return typeof globalThis?.process !== "undefined" && process?.versions?.node != null;
185
+ }
183
186
 
184
187
  function arrayable(value) {
185
188
  const result = Array.isArray(value) ? value : value === null ? [] : value === void 0 ? [] : isString(value) ? value.split(",").map((v) => v.trim()).filter(Boolean) : [value];
@@ -291,13 +294,50 @@ function groupBy(array, keyBy, objectMode) {
291
294
 
292
295
  function intersection(...arrays) {
293
296
  if (arrays.length === 0) return [];
294
- if (arrays.length === 1) return arrays[0];
297
+ if (arrays.length === 1) return [...arrays[0]];
295
298
  return arrays.reduce((acc, curr) => {
296
299
  const set = new Set(curr);
297
300
  return acc.filter((item) => set.has(item));
298
301
  });
299
302
  }
300
303
 
304
+ function intersectionBy(keyBy, ...arrays) {
305
+ var arraysLength = arrays.length;
306
+ if (arraysLength === 0) return [];
307
+ if (arraysLength === 1) return [...arrays[0]];
308
+ var getItemKey = isFunction(keyBy) ? keyBy : (item) => item?.[keyBy];
309
+ arrays = arrays.toSorted((a, b) => a.length - b.length);
310
+ var arrayLengths = [arraysLength];
311
+ var arrayIndices = [0];
312
+ var arraySets = [/* @__PURE__ */ new Set()];
313
+ var key1, key2;
314
+ var i;
315
+ for (i = 1; i < arraysLength; i++) {
316
+ arrayLengths[i] = arrays[i].length;
317
+ arrayIndices[i] = 0;
318
+ arraySets[i] = /* @__PURE__ */ new Set();
319
+ }
320
+ return arrays[0].filter((item) => {
321
+ key1 = getItemKey(item);
322
+ if (arraySets[0].has(key1)) return false;
323
+ arraySets[0].add(key1);
324
+ loop: for (i = 1; i < arraysLength; i++) {
325
+ if (arraySets[i].has(key1)) {
326
+ continue loop;
327
+ }
328
+ for (; arrayIndices[i] < arrayLengths[i]; arrayIndices[i]++) {
329
+ key2 = getItemKey(arrays[i][arrayIndices[i]]);
330
+ arraySets[i].add(key2);
331
+ if (Object.is(key1, key2)) {
332
+ continue loop;
333
+ }
334
+ }
335
+ return false;
336
+ }
337
+ return true;
338
+ });
339
+ }
340
+
301
341
  function keyBy(array, keyBy2, objectMode) {
302
342
  const getItemKey = isFunction(keyBy2) ? keyBy2 : (item) => item?.[keyBy2];
303
343
  if (objectMode === true) {
@@ -824,9 +864,14 @@ class BrowserAssertionError extends Error {
824
864
  }
825
865
 
826
866
  let AssertionError = BrowserAssertionError;
827
- if (!globalThis.window) {
828
- import('node:assert').then((r) => AssertionError = r.AssertionError).catch(() => {
829
- });
867
+ if (isNode()) {
868
+ try {
869
+ const assert = require("node:assert");
870
+ if (assert.AssertionError) {
871
+ AssertionError = assert.AssertionError;
872
+ }
873
+ } catch {
874
+ }
830
875
  }
831
876
 
832
877
  function ok(value, message) {
@@ -1760,178 +1805,539 @@ function uint8ToUint32(value) {
1760
1805
  return uint32Array;
1761
1806
  }
1762
1807
 
1763
- const objectKeys = /* @__PURE__ */ new WeakMap();
1764
- const BSON_TYPES = Object.freeze(/* @__PURE__ */ new Set(["ObjectID", "ObjectId"]));
1765
- const SYM_WITH_CACHE = Symbol();
1766
- const argToKey = (value, options = { objectStrategy: "ref" }) => {
1767
- let result = "";
1768
- if (isObject(value)) {
1769
- if (BSON_TYPES.has(value?._bsontype)) {
1770
- return String(value);
1771
- }
1772
- let key;
1773
- if (options.objectStrategy === "json") {
1774
- key = JSON.stringify(value);
1775
- } else {
1776
- key = objectKeys.get(value);
1777
- if (!key) {
1778
- key = createRadomKey();
1779
- objectKeys.set(value, key);
1780
- }
1808
+ const DateType = {
1809
+ placeholder: "$date",
1810
+ encode: (value) => {
1811
+ if (value instanceof Date) {
1812
+ return value.getTime();
1781
1813
  }
1782
- return key;
1783
- } else if (Array.isArray(value)) {
1784
- result += value.map((v) => argToKey(v, options)).join("/");
1785
- } else {
1786
- result = String(value);
1814
+ },
1815
+ decode(value) {
1816
+ return new Date(value);
1787
1817
  }
1788
- return result;
1789
1818
  };
1790
- function createRadomKey() {
1791
- return Date.now() + "_" + randomString(16);
1792
- }
1793
-
1794
- function createWithCache({
1795
- fn,
1796
- getPointer,
1797
- getBucket,
1798
- objectStrategy = "ref"
1799
- }) {
1800
- const isAsync = fn.constructor.name === "AsyncFunction";
1801
- const argToKeyOptions = { objectStrategy };
1802
- const $cache = {
1803
- getBucket: () => getBucket(getPointer()),
1804
- getPointer,
1805
- argToKeyOptions
1806
- };
1807
- const wrapFn = function(...args) {
1808
- const storage = getBucket(getPointer());
1809
- const cacheKey = args.map((v) => argToKey(v, argToKeyOptions)).join("_");
1810
- if (storage.has(cacheKey)) {
1811
- const value = storage.get(cacheKey);
1812
- return isAsync ? Promise.resolve(value) : value;
1819
+ const BinaryType = {
1820
+ placeholder: "$binary",
1821
+ encode: (value) => {
1822
+ if (value instanceof Uint8Array) {
1823
+ return base64.encode(value, { includePadding: true });
1824
+ } else if (value instanceof Uint16Array) {
1825
+ return {
1826
+ value: base64.encode(uint16ToUint8(value), { includePadding: true }),
1827
+ bit: 16
1828
+ };
1829
+ } else if (value instanceof Uint32Array) {
1830
+ return {
1831
+ value: base64.encode(uint32ToUint8(value), { includePadding: true }),
1832
+ bit: 32
1833
+ };
1813
1834
  }
1814
- const newValue = fn.apply(this, args);
1815
- if (isPromise(newValue)) {
1816
- return newValue.then((value) => {
1817
- storage.set(cacheKey, value);
1818
- return value;
1819
- });
1835
+ },
1836
+ decode(value) {
1837
+ if (typeof value === "string") {
1838
+ return base64.decode(value, { strict: true });
1839
+ } else if (value.bit === 16) {
1840
+ return uint8ToUint16(base64.decode(value.value, { strict: true }));
1841
+ } else if (value.bit === 32) {
1842
+ return uint8ToUint32(base64.decode(value.value, { strict: true }));
1820
1843
  }
1821
- storage.set(cacheKey, newValue);
1822
- return newValue;
1823
- };
1824
- wrapFn.$cache = $cache;
1825
- def(wrapFn, SYM_WITH_CACHE, true);
1826
- return wrapFn;
1827
- }
1828
- function isWithCache(value) {
1829
- return !!value && value[SYM_WITH_CACHE] === true;
1830
- }
1831
-
1832
- const cache = /* @__PURE__ */ new WeakMap();
1833
- function withCache(...args) {
1834
- let options = {};
1835
- let fn = noop;
1836
- if (isFunction(args[0])) {
1837
- fn = args[0];
1838
- } else if (isFunction(args[1])) {
1839
- options = args[0] || {};
1840
- fn = args[1];
1844
+ throw new Error("Unexpected $binary bit value: " + value.bit);
1841
1845
  }
1842
- const pointer = options.cachePointer || fn;
1843
- const getPointer = () => pointer;
1844
- const getBucket = (pointer2) => {
1845
- let fnCache = cache.get(pointer2);
1846
- if (!fnCache) {
1847
- fnCache = /* @__PURE__ */ new Map();
1848
- cache.set(pointer2, fnCache);
1846
+ };
1847
+ const BigIntType = {
1848
+ placeholder: "$bigint",
1849
+ encode: (value) => {
1850
+ if (typeof value === "bigint") {
1851
+ return base64.encode(bigIntBytes(value), { includePadding: false });
1849
1852
  }
1850
- return fnCache;
1851
- };
1852
- return createWithCache({
1853
- fn,
1854
- getBucket,
1855
- getPointer,
1856
- ...options
1857
- });
1858
- }
1859
-
1860
- function assertCapacity(value) {
1861
- number$1(value, "capacity must be a number");
1862
- ok(value > 0, "capacity must be more then 0.");
1863
- }
1864
-
1865
- class FixedMap extends Map {
1866
- constructor(_capacity) {
1867
- assertCapacity(_capacity);
1868
- super();
1869
- this._capacity = _capacity;
1870
- this._tail = [];
1853
+ },
1854
+ decode(value) {
1855
+ return bigIntFromBytes(base64.decode(value, { strict: false }));
1871
1856
  }
1872
- _tail;
1873
- set(key, value) {
1874
- if (!super.has.call(this, key)) {
1875
- this._tail.push(key);
1857
+ };
1858
+ const MapType = {
1859
+ placeholder: "$map",
1860
+ encode: (value, encode) => {
1861
+ if (value instanceof Map) {
1862
+ return encode(Array.from(value.entries()));
1876
1863
  }
1877
- super.set.call(this, key, value);
1878
- this._drain();
1879
- return this;
1864
+ },
1865
+ decode(value) {
1866
+ return new Map(value);
1880
1867
  }
1881
- delete(key) {
1882
- const removed = super.delete.call(this, key);
1883
- if (removed) {
1884
- const idx = this._tail.findIndex((v) => v === key);
1885
- if (idx > -1) {
1886
- this._tail.splice(idx, 1);
1887
- }
1868
+ };
1869
+ const SetType = {
1870
+ placeholder: "$set",
1871
+ encode: (value, encode) => {
1872
+ if (value instanceof Set) {
1873
+ return encode(Array.from(value.values()));
1888
1874
  }
1889
- return removed;
1890
- }
1891
- clear() {
1892
- delete this._tail;
1893
- this._tail = [];
1894
- super.clear.call(this);
1895
- }
1896
- get capacity() {
1897
- return this._capacity;
1898
- }
1899
- set capacity(value) {
1900
- assertCapacity(value);
1901
- this._capacity = value;
1902
- this._drain();
1875
+ },
1876
+ decode(value) {
1877
+ return new Set(value);
1903
1878
  }
1904
- _drain() {
1905
- while (this._tail.length > this._capacity) {
1906
- const key = this._tail.shift();
1907
- key !== void 0 && this.delete(key);
1879
+ };
1880
+ const RegexType = {
1881
+ placeholder: "$regex",
1882
+ encode: (value, encode) => {
1883
+ if (value instanceof RegExp) {
1884
+ const regStr = value.toString();
1885
+ const patternStart = regStr.lastIndexOf("/");
1886
+ return {
1887
+ pattern: value.toString().slice(1, patternStart),
1888
+ flags: regStr.slice(patternStart + 1)
1889
+ };
1908
1890
  }
1891
+ },
1892
+ decode(value) {
1893
+ return new RegExp(value.pattern, value.flags);
1909
1894
  }
1910
- }
1911
-
1912
- class TimeBucket {
1913
- _pointer;
1914
- _sizeMs;
1915
- _bucket;
1916
- constructor({ capacity = Infinity, sizeMs }) {
1917
- assetSizeMs(sizeMs);
1918
- this._sizeMs = sizeMs;
1919
- this._pointer = 0;
1920
- this._bucket = capacity === Infinity ? /* @__PURE__ */ new Map() : new FixedMap(capacity);
1921
- }
1922
- get capacity() {
1923
- if (this._bucket instanceof FixedMap) {
1924
- return this._bucket.capacity;
1895
+ };
1896
+ const InfinityType = {
1897
+ placeholder: "$inf",
1898
+ encode: (value, encode) => {
1899
+ if (value === Infinity) {
1900
+ return 1;
1901
+ } else if (value === -Infinity) {
1902
+ return -1;
1925
1903
  }
1926
- return Infinity;
1927
- }
1928
- get sizeMs() {
1929
- return this.sizeMs;
1904
+ },
1905
+ decode(value) {
1906
+ if (value === 1) return Infinity;
1907
+ if (value === -1) return -Infinity;
1908
+ throw new Error("Unexpected $inf value: " + value);
1930
1909
  }
1931
- set sizeMs(value) {
1932
- assetSizeMs(value);
1933
- this._sizeMs = value;
1934
- this._drainBucket();
1910
+ };
1911
+
1912
+ class EJSON {
1913
+ /** @internal */
1914
+ typeHandlers = /* @__PURE__ */ new Map();
1915
+ /** @internal */
1916
+ replacerReady;
1917
+ /** @internal */
1918
+ encode;
1919
+ /** @internal */
1920
+ reviewerReady;
1921
+ /** @internal */
1922
+ pure = true;
1923
+ _vendorName = null;
1924
+ /**
1925
+ * MIME type based on the provided vendor name or defaults to 'application/json'.
1926
+ */
1927
+ mimetype = "application/json";
1928
+ Type = {
1929
+ Date: DateType,
1930
+ Map: MapType,
1931
+ Set: SetType,
1932
+ RegExp: RegexType,
1933
+ Infinity: InfinityType,
1934
+ BigInt: BigIntType,
1935
+ Binary: BinaryType
1936
+ };
1937
+ constructor() {
1938
+ this.replacerReady = this._replacer.bind(this);
1939
+ this.reviewerReady = this._reviewer.bind(this);
1940
+ this.encode = (value) => {
1941
+ return deepCloneWith(value, this.replacerReady);
1942
+ };
1943
+ }
1944
+ /**
1945
+ * The vendor name used for the custom MIME type definition.
1946
+ * If null, defaults to 'application/json'.
1947
+ */
1948
+ get vendorName() {
1949
+ return this._vendorName;
1950
+ }
1951
+ set vendorName(value) {
1952
+ this._vendorName = value;
1953
+ if (!value) {
1954
+ this.mimetype = "application/json";
1955
+ } else {
1956
+ const vendorName = value.split(" ").map((v) => v.toLowerCase()).join(".").replace(/\.\.+/g, ".").replace(/\.$/, "");
1957
+ this.mimetype = `application/vnd.${vendorName}+json`;
1958
+ }
1959
+ }
1960
+ /**
1961
+ * Adds a custom type handler for encoding/decoding logic.
1962
+ * Ensures type placeholders are unique and adhere to conventions.
1963
+ */
1964
+ addType(type) {
1965
+ ok(
1966
+ !this.typeHandlers.has(type.placeholder),
1967
+ `type with ${type.placeholder} already taken.`
1968
+ );
1969
+ ok(
1970
+ type.placeholder.startsWith("$"),
1971
+ "type placeholder must starts with $ symbol."
1972
+ );
1973
+ this.pure = false;
1974
+ this.typeHandlers.set(type.placeholder, type);
1975
+ return this;
1976
+ }
1977
+ /**
1978
+ * Stringifies a JavaScript value using custom encoding logic.
1979
+ * @param {any} value - The value to encode and stringify.
1980
+ * @param {string | number} [space] - Optional space for pretty-printing.
1981
+ * @returns {string} - The JSON stringified value.
1982
+ */
1983
+ stringify(value, space) {
1984
+ if (this.pure) {
1985
+ return JSON.stringify(value, void 0, space);
1986
+ }
1987
+ return JSON.stringify(this.encode(value), void 0, space);
1988
+ }
1989
+ /**
1990
+ * Parses a JSON string using custom decoding logic.
1991
+ * @param {string} value - The JSON string to parse.
1992
+ * @returns {any} - The decoded JavaScript object.
1993
+ */
1994
+ parse(value) {
1995
+ if (this.pure) {
1996
+ return JSON.parse(value);
1997
+ }
1998
+ return JSON.parse(value, this.reviewerReady);
1999
+ }
2000
+ /** @internal */
2001
+ _replacer(value, key) {
2002
+ if (isPlainObject(value)) return;
2003
+ if (Array.isArray(value)) return;
2004
+ if (!isInfinity(value) && !isBigInt(value)) {
2005
+ if (isPrimitive(value)) return;
2006
+ }
2007
+ for (const type of this.typeHandlers.values()) {
2008
+ const res = type.encode(value, this.encode);
2009
+ if (res !== void 0) {
2010
+ return type.encodeInline ? res : { [type.placeholder]: res };
2011
+ }
2012
+ }
2013
+ return value;
2014
+ }
2015
+ /** @internal */
2016
+ _reviewer(_, value) {
2017
+ const key = firstKey(value);
2018
+ if (!key || key[0] !== "$") return value;
2019
+ const type = this.typeHandlers.get(key);
2020
+ if (type) {
2021
+ return type.decode(value[key]);
2022
+ }
2023
+ return value;
2024
+ }
2025
+ }
2026
+ function firstKey(value) {
2027
+ if (!isObject(value)) return null;
2028
+ for (const key in value) {
2029
+ return key;
2030
+ }
2031
+ return null;
2032
+ }
2033
+
2034
+ function createEJSON(withBasicTypes = false) {
2035
+ const ejson = new EJSON();
2036
+ if (withBasicTypes) {
2037
+ ejson.addType(MapType);
2038
+ ejson.addType(SetType);
2039
+ ejson.addType(DateType);
2040
+ ejson.addType(InfinityType);
2041
+ ejson.addType(BigIntType);
2042
+ ejson.addType(BinaryType);
2043
+ ejson.addType(RegexType);
2044
+ }
2045
+ return ejson;
2046
+ }
2047
+
2048
+ class EJSONStream extends TransformStream {
2049
+ ejson;
2050
+ constructor({ ejson, cl, op, sep, onFlush, onStart }) {
2051
+ let firstChunk = true;
2052
+ super({
2053
+ start(controller) {
2054
+ return Promise.resolve().then(() => {
2055
+ if (onStart) {
2056
+ return onStart(controller);
2057
+ }
2058
+ }).then(() => {
2059
+ controller.enqueue(op);
2060
+ });
2061
+ },
2062
+ transform(chunk, controller) {
2063
+ const jsonString = ejson.stringify(chunk);
2064
+ if (firstChunk) {
2065
+ firstChunk = false;
2066
+ } else {
2067
+ controller.enqueue(sep);
2068
+ }
2069
+ controller.enqueue(jsonString);
2070
+ },
2071
+ flush(controller) {
2072
+ controller.enqueue(cl);
2073
+ if (onFlush) {
2074
+ return onFlush(controller);
2075
+ }
2076
+ }
2077
+ });
2078
+ this.ejson = ejson;
2079
+ }
2080
+ /**
2081
+ * The vendor name used for the custom MIME type definition.
2082
+ * If null, defaults to 'application/json'.
2083
+ */
2084
+ get vendorName() {
2085
+ return this.ejson.vendorName;
2086
+ }
2087
+ /**
2088
+ * MIME type based on the provided vendor name or defaults to 'application/json'.
2089
+ */
2090
+ get mimetype() {
2091
+ return this.ejson.mimetype;
2092
+ }
2093
+ }
2094
+
2095
+ const instance = createEJSON(true);
2096
+
2097
+ function createEJSONStream(options = {}) {
2098
+ if (options.resultKey || options.append || options.prepend) {
2099
+ return createEJSONStreamPayload(options);
2100
+ }
2101
+ return new EJSONStream(getOptions(options));
2102
+ }
2103
+ function createEJSONStreamPayload(options) {
2104
+ let { cl, ejson, op, sep } = getOptions(options);
2105
+ const { append, prepend, resultKey } = options;
2106
+ notEmptyString(resultKey, "resultKey required.");
2107
+ const stream = new EJSONStream({
2108
+ ejson,
2109
+ cl,
2110
+ op,
2111
+ sep,
2112
+ onStart(controller) {
2113
+ if (!prepend) {
2114
+ controller.enqueue(`{"${resultKey}":`);
2115
+ return Promise.resolve();
2116
+ }
2117
+ return Promise.resolve().then(() => prepend()).then((data) => {
2118
+ if (data === null || data === void 0) {
2119
+ controller.enqueue(`{"${resultKey}":`);
2120
+ return;
2121
+ }
2122
+ ok(
2123
+ isPlainObject(data),
2124
+ "prepend result expected to be plain object"
2125
+ );
2126
+ const dataPart = instance.stringify(data).slice(0, -1);
2127
+ if (dataPart === "{") {
2128
+ controller.enqueue(`{"${resultKey}":`);
2129
+ return;
2130
+ }
2131
+ controller.enqueue(`${dataPart}${sep}"${resultKey}":`);
2132
+ });
2133
+ },
2134
+ onFlush(controller) {
2135
+ if (!append) {
2136
+ controller.enqueue("}");
2137
+ return Promise.resolve();
2138
+ }
2139
+ return Promise.resolve().then(() => append()).then((data) => {
2140
+ if (data === null || data === void 0) {
2141
+ controller.enqueue("}");
2142
+ return;
2143
+ }
2144
+ ok(
2145
+ isPlainObject(data),
2146
+ "prepend result expected to be plain object"
2147
+ );
2148
+ const dataPart = instance.stringify(data).slice(1);
2149
+ if (dataPart === "}") {
2150
+ controller.enqueue(`}`);
2151
+ return;
2152
+ }
2153
+ controller.enqueue(`${sep}${dataPart}`);
2154
+ });
2155
+ }
2156
+ });
2157
+ return stream;
2158
+ }
2159
+ function getOptions(options) {
2160
+ const { ejson = instance, cl = "]", op = "[", sep = "," } = options;
2161
+ return {
2162
+ cl,
2163
+ ejson,
2164
+ op,
2165
+ sep
2166
+ };
2167
+ }
2168
+
2169
+ const objectKeys = /* @__PURE__ */ new WeakMap();
2170
+ const BSON_TYPES = Object.freeze(/* @__PURE__ */ new Set(["ObjectID", "ObjectId"]));
2171
+ const SYM_WITH_CACHE = Symbol();
2172
+ const argToKey = (value, options = { objectStrategy: "ref" }) => {
2173
+ let result = "";
2174
+ if (isObject(value)) {
2175
+ if (BSON_TYPES.has(value?._bsontype)) {
2176
+ return String(value);
2177
+ }
2178
+ let key;
2179
+ if (options.objectStrategy === "json") {
2180
+ key = instance.stringify(value);
2181
+ } else {
2182
+ key = objectKeys.get(value);
2183
+ if (!key) {
2184
+ key = createRadomKey();
2185
+ objectKeys.set(value, key);
2186
+ }
2187
+ }
2188
+ return key;
2189
+ } else if (Array.isArray(value)) {
2190
+ result += value.map((v) => argToKey(v, options)).join("/");
2191
+ } else {
2192
+ result = String(value);
2193
+ }
2194
+ return result;
2195
+ };
2196
+ function createRadomKey() {
2197
+ return Date.now() + "_" + randomString(16);
2198
+ }
2199
+
2200
+ function createWithCache({
2201
+ fn,
2202
+ getPointer,
2203
+ getBucket,
2204
+ objectStrategy = "ref"
2205
+ }) {
2206
+ const isAsync = fn.constructor.name === "AsyncFunction";
2207
+ const argToKeyOptions = { objectStrategy };
2208
+ const $cache = {
2209
+ getBucket: () => getBucket(getPointer()),
2210
+ getPointer,
2211
+ argToKeyOptions
2212
+ };
2213
+ const wrapFn = function(...args) {
2214
+ const storage = getBucket(getPointer());
2215
+ const cacheKey = args.map((v) => argToKey(v, argToKeyOptions)).join("_");
2216
+ if (storage.has(cacheKey)) {
2217
+ const value = storage.get(cacheKey);
2218
+ return isAsync ? Promise.resolve(value) : value;
2219
+ }
2220
+ const newValue = fn.apply(this, args);
2221
+ if (isPromise(newValue)) {
2222
+ return newValue.then((value) => {
2223
+ storage.set(cacheKey, value);
2224
+ return value;
2225
+ });
2226
+ }
2227
+ storage.set(cacheKey, newValue);
2228
+ return newValue;
2229
+ };
2230
+ wrapFn.$cache = $cache;
2231
+ def(wrapFn, SYM_WITH_CACHE, true);
2232
+ return wrapFn;
2233
+ }
2234
+ function isWithCache(value) {
2235
+ return !!value && value[SYM_WITH_CACHE] === true;
2236
+ }
2237
+
2238
+ const cache = /* @__PURE__ */ new WeakMap();
2239
+ function withCache(...args) {
2240
+ let options = {};
2241
+ let fn = noop;
2242
+ if (isFunction(args[0])) {
2243
+ fn = args[0];
2244
+ } else if (isFunction(args[1])) {
2245
+ options = args[0] || {};
2246
+ fn = args[1];
2247
+ }
2248
+ const pointer = options.cachePointer || fn;
2249
+ const getPointer = () => pointer;
2250
+ const getBucket = (pointer2) => {
2251
+ let fnCache = cache.get(pointer2);
2252
+ if (!fnCache) {
2253
+ fnCache = /* @__PURE__ */ new Map();
2254
+ cache.set(pointer2, fnCache);
2255
+ }
2256
+ return fnCache;
2257
+ };
2258
+ return createWithCache({
2259
+ fn,
2260
+ getBucket,
2261
+ getPointer,
2262
+ ...options
2263
+ });
2264
+ }
2265
+
2266
+ function assertCapacity(value) {
2267
+ number$1(value, "capacity must be a number");
2268
+ ok(value > 0, "capacity must be more then 0.");
2269
+ }
2270
+
2271
+ class FixedMap extends Map {
2272
+ constructor(_capacity) {
2273
+ assertCapacity(_capacity);
2274
+ super();
2275
+ this._capacity = _capacity;
2276
+ this._tail = [];
2277
+ }
2278
+ _tail;
2279
+ set(key, value) {
2280
+ if (!super.has.call(this, key)) {
2281
+ this._tail.push(key);
2282
+ }
2283
+ super.set.call(this, key, value);
2284
+ this._drain();
2285
+ return this;
2286
+ }
2287
+ delete(key) {
2288
+ const removed = super.delete.call(this, key);
2289
+ if (removed) {
2290
+ const idx = this._tail.findIndex((v) => v === key);
2291
+ if (idx > -1) {
2292
+ this._tail.splice(idx, 1);
2293
+ }
2294
+ }
2295
+ return removed;
2296
+ }
2297
+ clear() {
2298
+ delete this._tail;
2299
+ this._tail = [];
2300
+ super.clear.call(this);
2301
+ }
2302
+ get capacity() {
2303
+ return this._capacity;
2304
+ }
2305
+ set capacity(value) {
2306
+ assertCapacity(value);
2307
+ this._capacity = value;
2308
+ this._drain();
2309
+ }
2310
+ _drain() {
2311
+ while (this._tail.length > this._capacity) {
2312
+ const key = this._tail.shift();
2313
+ key !== void 0 && this.delete(key);
2314
+ }
2315
+ }
2316
+ }
2317
+
2318
+ class TimeBucket {
2319
+ _pointer;
2320
+ _sizeMs;
2321
+ _bucket;
2322
+ constructor({ capacity = Infinity, sizeMs }) {
2323
+ assetSizeMs(sizeMs);
2324
+ this._sizeMs = sizeMs;
2325
+ this._pointer = 0;
2326
+ this._bucket = capacity === Infinity ? /* @__PURE__ */ new Map() : new FixedMap(capacity);
2327
+ }
2328
+ get capacity() {
2329
+ if (this._bucket instanceof FixedMap) {
2330
+ return this._bucket.capacity;
2331
+ }
2332
+ return Infinity;
2333
+ }
2334
+ get sizeMs() {
2335
+ return this.sizeMs;
2336
+ }
2337
+ set sizeMs(value) {
2338
+ assetSizeMs(value);
2339
+ this._sizeMs = value;
2340
+ this._drainBucket();
1935
2341
  }
1936
2342
  get size() {
1937
2343
  this._drainBucket();
@@ -3417,678 +3823,317 @@ var TABLE = new Int32Array([
3417
3823
  755167117
3418
3824
  ]);
3419
3825
  function crc32(value, seed) {
3420
- if (isString(value)) {
3421
- return crc32(textEncoder.encode(value), seed);
3422
- }
3423
- var crc = seed === 0 ? 0 : ~~seed ^ -1;
3424
- if (value instanceof Uint8Array) {
3425
- for (var index = 0; index < value.length; index++) {
3426
- crc = TABLE[(crc ^ value[index]) & 255] ^ crc >>> 8;
3427
- }
3428
- } else {
3429
- for (var current of value) {
3430
- for (var index = 0; index < current.length; index++) {
3431
- crc = TABLE[(crc ^ current[index]) & 255] ^ crc >>> 8;
3432
- }
3433
- }
3434
- }
3435
- return crc ^ -1;
3436
- }
3437
-
3438
- function isDateObject(value) {
3439
- return has(value, ["year", "month", "date"]) && isNumber(value.year) && isNumber(value.month) && isNumber(value.date);
3440
- }
3441
-
3442
- function createDateObject(value, returnsNullWhenInvalid = false) {
3443
- let result = null;
3444
- let inputValue = value;
3445
- if (isNumber(inputValue) || isString(inputValue)) {
3446
- inputValue = new Date(inputValue);
3447
- }
3448
- if (isDate(inputValue)) {
3449
- result = {
3450
- year: inputValue.getFullYear(),
3451
- month: inputValue.getMonth() + 1,
3452
- date: inputValue.getDate()
3453
- };
3454
- } else if (isDateObject(inputValue)) {
3455
- result = { ...inputValue };
3456
- }
3457
- ok(
3458
- returnsNullWhenInvalid || !!result,
3459
- `Failed to date parse: ${value}.`
3460
- );
3461
- return result;
3462
- }
3463
-
3464
- function isTimeObject(value) {
3465
- return isPlainObject(value) && "h" in value && "m" in value && isNumber(value.h) && Number.isInteger(value.h) && isNumber(value.m) && Number.isInteger(value.m) && value.h >= 0 && value.h < 24 && value.m >= 0 && value.m < 60;
3466
- }
3467
-
3468
- function createTimeObject(value, returnsNullWhenInvalid = false) {
3469
- let result = null;
3470
- let inputValue = value;
3471
- if (isNumber(inputValue)) {
3472
- inputValue = new Date(inputValue);
3473
- } else if (isString(inputValue)) {
3474
- const [h, m] = inputValue.split(":").map((v) => v.trim().padStart(2, "0")).map((v) => parseInt(v));
3475
- inputValue = { h, m };
3476
- }
3477
- if (isDate(inputValue)) {
3478
- result = {
3479
- h: inputValue.getHours(),
3480
- m: inputValue.getMinutes()
3481
- };
3482
- } else if (isTimeObject(inputValue)) {
3483
- result = { ...inputValue };
3484
- }
3485
- ok(
3486
- returnsNullWhenInvalid || !!result,
3487
- `Failed to time parse: ${value}.`
3488
- );
3489
- return result;
3490
- }
3491
-
3492
- const UNIT_TO_MS = {
3493
- ms: 1,
3494
- s: 1e3,
3495
- m: 1e3 * 60,
3496
- h: 1e3 * 60 * 60,
3497
- d: 1e3 * 60 * 60 * 24,
3498
- w: 1e3 * 60 * 60 * 24 * 7
3499
- };
3500
- class TimeSpan {
3501
- constructor(value, unit) {
3502
- this.value = value;
3503
- this.unit = unit;
3504
- }
3505
- /**
3506
- * The numeric value of the time span
3507
- */
3508
- value;
3509
- /**
3510
- * The unit of the time span.
3511
- */
3512
- unit;
3513
- /**
3514
- * Converts the time span to milliseconds.
3515
- *
3516
- * @returns {number} The equivalent time span in milliseconds.
3517
- * @example
3518
- * const ts = new TimeSpan(2, 'h');
3519
- * ts.milliseconds(); // Returns 7200000
3520
- */
3521
- milliseconds() {
3522
- const multiplier = UNIT_TO_MS[this.unit];
3523
- return this.value * multiplier;
3524
- }
3525
- /**
3526
- * Converts the time span to seconds.
3527
- *
3528
- * @returns {number} The equivalent time span in seconds.
3529
- * @example
3530
- * const ts = new TimeSpan(2, 'm');
3531
- * ts.seconds(); // Returns 120
3532
- */
3533
- seconds() {
3534
- return this.milliseconds() / UNIT_TO_MS.s;
3535
- }
3536
- /**
3537
- * Converts the time span to minutes.
3538
- *
3539
- * @returns {number} The equivalent time span in minutes.
3540
- * @example
3541
- * const ts = new TimeSpan(120, 's');
3542
- * ts.minutes(); // Returns 2
3543
- */
3544
- minutes() {
3545
- return this.milliseconds() / UNIT_TO_MS.m;
3546
- }
3547
- /**
3548
- * Converts the time span to hours.
3549
- *
3550
- * @returns {number} The equivalent time span in hours.
3551
- * @example
3552
- * const ts = new TimeSpan(120, 'm');
3553
- * ts.hours(); // Returns 2
3554
- */
3555
- hours() {
3556
- return this.milliseconds() / UNIT_TO_MS.h;
3557
- }
3558
- /**
3559
- * Converts the time span to days.
3560
- *
3561
- * @returns {number} The equivalent time span in days.
3562
- * @example
3563
- * const ts = new TimeSpan(48, 'h');
3564
- * ts.days(); // Returns 2
3565
- */
3566
- days() {
3567
- return this.milliseconds() / UNIT_TO_MS.d;
3568
- }
3569
- /**
3570
- * Converts the time span to weeks.
3571
- *
3572
- * @returns {number} The equivalent time span in weeks.
3573
- * @example
3574
- * const ts = new TimeSpan(14, 'd');
3575
- * ts.weeks(); // Returns 2
3576
- */
3577
- weeks() {
3578
- return this.milliseconds() / UNIT_TO_MS.w;
3579
- }
3580
- /**
3581
- * Adds a specified value and unit to the current time span.
3582
- *
3583
- * Returns new instance.
3584
- *
3585
- * @param {number} value - The value to add.
3586
- * @param {TimeSpanUnit} [unit='ms'] - The unit of the value to add (default is milliseconds).
3587
- * @returns {TimeSpan} A new TimeSpan instance with the added value.
3588
- * @example
3589
- * const ts = new TimeSpan(1, 'h');
3590
- * ts.add(30, 'm'); // Represents 1.5 hours
3591
- */
3592
- add(value, unit = "ms") {
3593
- const multiplier = UNIT_TO_MS[unit];
3594
- return new TimeSpan(this.milliseconds() + value * multiplier, "ms");
3595
- }
3596
- /**
3597
- * Subtracts a specified value and unit from the current time span.
3598
- *
3599
- * Returns new instance.
3600
- *
3601
- * @param {number} value - The value to subtract.
3602
- * @param {TimeSpanUnit} [unit='ms'] - The unit of the value to subtract (default is milliseconds).
3603
- * @returns {TimeSpan} A new TimeSpan instance with the subtracted value.
3604
- * @example
3605
- * const ts = new TimeSpan(1, 'h');
3606
- * ts.subtract(30, 'm'); // Represents 30 minutes less than 1 hour
3607
- */
3608
- subtract(value, unit = "ms") {
3609
- const multiplier = UNIT_TO_MS[unit];
3610
- return new TimeSpan(this.milliseconds() - value * multiplier, "ms");
3826
+ if (isString(value)) {
3827
+ return crc32(textEncoder.encode(value), seed);
3611
3828
  }
3612
- }
3613
-
3614
- function createTimeSpan(value, unit = "ms") {
3615
- return new TimeSpan(value, unit);
3616
- }
3617
-
3618
- function timestampMs(fromValue = Date.now()) {
3619
- if (isDate(fromValue)) {
3620
- fromValue = fromValue.getTime();
3621
- } else if (isString(fromValue)) {
3622
- const dt = new Date(fromValue);
3623
- fromValue = isDate(dt) ? dt.getTime() : 0;
3829
+ var crc = seed === 0 ? 0 : ~~seed ^ -1;
3830
+ if (value instanceof Uint8Array) {
3831
+ for (var index = 0; index < value.length; index++) {
3832
+ crc = TABLE[(crc ^ value[index]) & 255] ^ crc >>> 8;
3833
+ }
3834
+ } else {
3835
+ for (var current of value) {
3836
+ for (var index = 0; index < current.length; index++) {
3837
+ crc = TABLE[(crc ^ current[index]) & 255] ^ crc >>> 8;
3838
+ }
3839
+ }
3624
3840
  }
3625
- return isNumber(fromValue) ? fromValue : 0;
3626
- }
3627
-
3628
- function dateInDays(days, fromValue = Date.now()) {
3629
- return new Date(timestampMs(fromValue) + days * 60 * 60 * 24 * 1e3);
3841
+ return crc ^ -1;
3630
3842
  }
3631
3843
 
3632
- function dateInSeconds(seconds, fromValue = Date.now()) {
3633
- return new Date(timestampMs(fromValue) + seconds * 1e3);
3844
+ function isDateObject(value) {
3845
+ return has(value, ["year", "month", "date"]) && isNumber(value.year) && isNumber(value.month) && isNumber(value.date);
3634
3846
  }
3635
3847
 
3636
- function getRandomTime(startTime = { h: 0, m: 0 }, endTime = { h: 23, m: 59 }) {
3637
- const h = getRandomInt(startTime.h, endTime.h);
3638
- if (startTime.h === endTime.h) {
3639
- return { h, m: getRandomInt(startTime.m, endTime.m) };
3640
- }
3641
- if (h === startTime.h) {
3642
- return { h, m: getRandomInt(startTime.m, 59) };
3848
+ function createDateObject(value, returnsNullWhenInvalid = false) {
3849
+ let result = null;
3850
+ let inputValue = value;
3851
+ if (isNumber(inputValue) || isString(inputValue)) {
3852
+ inputValue = new Date(inputValue);
3643
3853
  }
3644
- if (h === endTime.h) {
3645
- return { h, m: getRandomInt(0, endTime.m) };
3854
+ if (isDate(inputValue)) {
3855
+ result = {
3856
+ year: inputValue.getFullYear(),
3857
+ month: inputValue.getMonth() + 1,
3858
+ date: inputValue.getDate()
3859
+ };
3860
+ } else if (isDateObject(inputValue)) {
3861
+ result = { ...inputValue };
3646
3862
  }
3647
- return { h, m: getRandomInt(0, 59) };
3648
- }
3649
-
3650
- function hmToSeconds(hm) {
3651
- hm = Number(hm);
3652
- number$1(hm, "expected number value");
3653
- const h = Math.floor(hm);
3654
- const m = round2digits(hm - h) * 100;
3655
- return h * 3600 + m * 60;
3656
- }
3657
-
3658
- function isTimeString(value) {
3659
- if (!isString(value)) return false;
3660
- const parts = value.split(":").map(Number);
3661
- if (parts.length !== 2) return false;
3662
- const [h, m] = parts;
3663
- return h >= 0 && h < 24 && m >= 0 && m < 60;
3664
- }
3665
-
3666
- function isTimeValue(value) {
3667
- return isTimeString(value) || isTimeObject(value);
3668
- }
3669
-
3670
- function isValidWeekDay(value) {
3671
- return isNumber(value) && Number.isInteger(value) && value >= 1 && value <= 7;
3863
+ ok(
3864
+ returnsNullWhenInvalid || !!result,
3865
+ `Failed to date parse: ${value}.`
3866
+ );
3867
+ return result;
3672
3868
  }
3673
3869
 
3674
- function secondsToHm(seconds) {
3675
- const value = Number(seconds);
3676
- number$1(value, "expected number value");
3677
- const h = Math.floor(value / 3600);
3678
- const m = Math.floor(value % 3600 / 60);
3679
- return round2digits(h + m / 100, 2);
3870
+ function isTimeObject(value) {
3871
+ return isPlainObject(value) && "h" in value && "m" in value && isNumber(value.h) && Number.isInteger(value.h) && isNumber(value.m) && Number.isInteger(value.m) && value.h >= 0 && value.h < 24 && value.m >= 0 && value.m < 60;
3680
3872
  }
3681
3873
 
3682
- function timeFromMinutes(value, returnsNullWhenInvalid = false) {
3683
- if (!isNumber(value)) {
3684
- ok(
3685
- returnsNullWhenInvalid,
3686
- "Failed to time parse from minutes: " + value
3687
- );
3688
- return null;
3689
- }
3690
- if (value === 0) {
3691
- return { h: 0, m: 0 };
3692
- }
3693
- value = value % 1440;
3694
- if (value < 0) {
3695
- value += 1440;
3874
+ function createTimeObject(value, returnsNullWhenInvalid = false) {
3875
+ let result = null;
3876
+ let inputValue = value;
3877
+ if (isNumber(inputValue)) {
3878
+ inputValue = new Date(inputValue);
3879
+ } else if (isString(inputValue)) {
3880
+ const [h, m] = inputValue.split(":").map((v) => v.trim().padStart(2, "0")).map((v) => parseInt(v));
3881
+ inputValue = { h, m };
3696
3882
  }
3697
- const h = Math.floor(value / 60);
3698
- const m = value % 60;
3699
- return { h, m };
3700
- }
3701
-
3702
- function timestampToDate(value) {
3703
- if (!isNumber(value)) return null;
3704
- return new Date(value * 1e3);
3705
- }
3706
-
3707
- function timeStringify(value, returnsNullWhenInvalid = false) {
3708
- const timeObject = createTimeObject(value, true);
3709
- if (!timeObject) {
3710
- ok(
3711
- returnsNullWhenInvalid,
3712
- "Failed to stringify time from: " + JSON.stringify(value)
3713
- );
3714
- return null;
3883
+ if (isDate(inputValue)) {
3884
+ result = {
3885
+ h: inputValue.getHours(),
3886
+ m: inputValue.getMinutes()
3887
+ };
3888
+ } else if (isTimeObject(inputValue)) {
3889
+ result = { ...inputValue };
3715
3890
  }
3716
- let { h, m } = timeObject;
3717
- const hStr = Math.ceil(h).toString().padStart(2, "0").slice(-2);
3718
- const mStr = Math.ceil(m).toString().padStart(2, "0").slice(-2);
3719
- return `${hStr}:${mStr}`;
3720
- }
3721
-
3722
- function timeToMinutes(value) {
3723
- const time = createTimeObject(value);
3724
- return time.h * 60 + time.m;
3725
- }
3726
-
3727
- function weeksInYear(year) {
3728
- const target = new Date(Date.UTC(year + 1, 0, 1));
3729
- const dayNumber = target.getDay();
3730
- return dayNumber < 4 ? 52 : 53;
3891
+ ok(
3892
+ returnsNullWhenInvalid || !!result,
3893
+ `Failed to time parse: ${value}.`
3894
+ );
3895
+ return result;
3731
3896
  }
3732
3897
 
3733
- const DateType = {
3734
- placeholder: "$date",
3735
- encode: (value) => {
3736
- if (value instanceof Date) {
3737
- return value.getTime();
3738
- }
3739
- },
3740
- decode(value) {
3741
- return new Date(value);
3742
- }
3743
- };
3744
- const BinaryType = {
3745
- placeholder: "$binary",
3746
- encode: (value) => {
3747
- if (value instanceof Uint8Array) {
3748
- return base64.encode(value, { includePadding: true });
3749
- } else if (value instanceof Uint16Array) {
3750
- return {
3751
- value: base64.encode(uint16ToUint8(value), { includePadding: true }),
3752
- bit: 16
3753
- };
3754
- } else if (value instanceof Uint32Array) {
3755
- return {
3756
- value: base64.encode(uint32ToUint8(value), { includePadding: true }),
3757
- bit: 32
3758
- };
3759
- }
3760
- },
3761
- decode(value) {
3762
- if (typeof value === "string") {
3763
- return base64.decode(value, { strict: true });
3764
- } else if (value.bit === 16) {
3765
- return uint8ToUint16(base64.decode(value.value, { strict: true }));
3766
- } else if (value.bit === 32) {
3767
- return uint8ToUint32(base64.decode(value.value, { strict: true }));
3768
- }
3769
- throw new Error("Unexpected $binary bit value: " + value.bit);
3770
- }
3771
- };
3772
- const BigIntType = {
3773
- placeholder: "$bigint",
3774
- encode: (value) => {
3775
- if (typeof value === "bigint") {
3776
- return base64.encode(bigIntBytes(value), { includePadding: false });
3777
- }
3778
- },
3779
- decode(value) {
3780
- return bigIntFromBytes(base64.decode(value, { strict: false }));
3781
- }
3782
- };
3783
- const MapType = {
3784
- placeholder: "$map",
3785
- encode: (value, encode) => {
3786
- if (value instanceof Map) {
3787
- return encode(Array.from(value.entries()));
3788
- }
3789
- },
3790
- decode(value) {
3791
- return new Map(value);
3792
- }
3793
- };
3794
- const SetType = {
3795
- placeholder: "$set",
3796
- encode: (value, encode) => {
3797
- if (value instanceof Set) {
3798
- return encode(Array.from(value.values()));
3799
- }
3800
- },
3801
- decode(value) {
3802
- return new Set(value);
3803
- }
3898
+ const UNIT_TO_MS = {
3899
+ ms: 1,
3900
+ s: 1e3,
3901
+ m: 1e3 * 60,
3902
+ h: 1e3 * 60 * 60,
3903
+ d: 1e3 * 60 * 60 * 24,
3904
+ w: 1e3 * 60 * 60 * 24 * 7
3804
3905
  };
3805
- const RegexType = {
3806
- placeholder: "$regex",
3807
- encode: (value, encode) => {
3808
- if (value instanceof RegExp) {
3809
- const regStr = value.toString();
3810
- const patternStart = regStr.lastIndexOf("/");
3811
- return {
3812
- pattern: value.toString().slice(1, patternStart),
3813
- flags: regStr.slice(patternStart + 1)
3814
- };
3815
- }
3816
- },
3817
- decode(value) {
3818
- return new RegExp(value.pattern, value.flags);
3906
+ class TimeSpan {
3907
+ constructor(value, unit) {
3908
+ this.value = value;
3909
+ this.unit = unit;
3819
3910
  }
3820
- };
3821
- const InfinityType = {
3822
- placeholder: "$inf",
3823
- encode: (value, encode) => {
3824
- if (value === Infinity) {
3825
- return 1;
3826
- } else if (value === -Infinity) {
3827
- return -1;
3828
- }
3829
- },
3830
- decode(value) {
3831
- if (value === 1) return Infinity;
3832
- if (value === -1) return -Infinity;
3833
- throw new Error("Unexpected $inf value: " + value);
3911
+ /**
3912
+ * The numeric value of the time span
3913
+ */
3914
+ value;
3915
+ /**
3916
+ * The unit of the time span.
3917
+ */
3918
+ unit;
3919
+ /**
3920
+ * Converts the time span to milliseconds.
3921
+ *
3922
+ * @returns {number} The equivalent time span in milliseconds.
3923
+ * @example
3924
+ * const ts = new TimeSpan(2, 'h');
3925
+ * ts.milliseconds(); // Returns 7200000
3926
+ */
3927
+ milliseconds() {
3928
+ const multiplier = UNIT_TO_MS[this.unit];
3929
+ return this.value * multiplier;
3834
3930
  }
3835
- };
3836
-
3837
- class EJSON {
3838
- /** @internal */
3839
- typeHandlers = /* @__PURE__ */ new Map();
3840
- /** @internal */
3841
- replacerReady;
3842
- /** @internal */
3843
- encode;
3844
- /** @internal */
3845
- reviewerReady;
3846
- /** @internal */
3847
- pure = true;
3848
- _vendorName = null;
3849
3931
  /**
3850
- * MIME type based on the provided vendor name or defaults to 'application/json'.
3932
+ * Converts the time span to seconds.
3933
+ *
3934
+ * @returns {number} The equivalent time span in seconds.
3935
+ * @example
3936
+ * const ts = new TimeSpan(2, 'm');
3937
+ * ts.seconds(); // Returns 120
3851
3938
  */
3852
- mimetype = "application/json";
3853
- Type = {
3854
- Date: DateType,
3855
- Map: MapType,
3856
- Set: SetType,
3857
- RegExp: RegexType,
3858
- Infinity: InfinityType,
3859
- BigInt: BigIntType,
3860
- Binary: BinaryType
3861
- };
3862
- constructor() {
3863
- this.replacerReady = this._replacer.bind(this);
3864
- this.reviewerReady = this._reviewer.bind(this);
3865
- this.encode = (value) => {
3866
- return deepCloneWith(value, this.replacerReady);
3867
- };
3939
+ seconds() {
3940
+ return this.milliseconds() / UNIT_TO_MS.s;
3868
3941
  }
3869
3942
  /**
3870
- * The vendor name used for the custom MIME type definition.
3871
- * If null, defaults to 'application/json'.
3943
+ * Converts the time span to minutes.
3944
+ *
3945
+ * @returns {number} The equivalent time span in minutes.
3946
+ * @example
3947
+ * const ts = new TimeSpan(120, 's');
3948
+ * ts.minutes(); // Returns 2
3872
3949
  */
3873
- get vendorName() {
3874
- return this._vendorName;
3950
+ minutes() {
3951
+ return this.milliseconds() / UNIT_TO_MS.m;
3875
3952
  }
3876
- set vendorName(value) {
3877
- this._vendorName = value;
3878
- if (!value) {
3879
- this.mimetype = "application/json";
3880
- } else {
3881
- const vendorName = value.split(" ").map((v) => v.toLowerCase()).join(".").replace(/\.\.+/g, ".").replace(/\.$/, "");
3882
- this.mimetype = `application/vnd.${vendorName}+json`;
3883
- }
3953
+ /**
3954
+ * Converts the time span to hours.
3955
+ *
3956
+ * @returns {number} The equivalent time span in hours.
3957
+ * @example
3958
+ * const ts = new TimeSpan(120, 'm');
3959
+ * ts.hours(); // Returns 2
3960
+ */
3961
+ hours() {
3962
+ return this.milliseconds() / UNIT_TO_MS.h;
3884
3963
  }
3885
3964
  /**
3886
- * Adds a custom type handler for encoding/decoding logic.
3887
- * Ensures type placeholders are unique and adhere to conventions.
3965
+ * Converts the time span to days.
3966
+ *
3967
+ * @returns {number} The equivalent time span in days.
3968
+ * @example
3969
+ * const ts = new TimeSpan(48, 'h');
3970
+ * ts.days(); // Returns 2
3888
3971
  */
3889
- addType(type) {
3890
- ok(
3891
- !this.typeHandlers.has(type.placeholder),
3892
- `type with ${type.placeholder} already taken.`
3893
- );
3894
- ok(
3895
- type.placeholder.startsWith("$"),
3896
- "type placeholder must starts with $ symbol."
3897
- );
3898
- this.pure = false;
3899
- this.typeHandlers.set(type.placeholder, type);
3900
- return this;
3972
+ days() {
3973
+ return this.milliseconds() / UNIT_TO_MS.d;
3901
3974
  }
3902
3975
  /**
3903
- * Stringifies a JavaScript value using custom encoding logic.
3904
- * @param {any} value - The value to encode and stringify.
3905
- * @param {string | number} [space] - Optional space for pretty-printing.
3906
- * @returns {string} - The JSON stringified value.
3976
+ * Converts the time span to weeks.
3977
+ *
3978
+ * @returns {number} The equivalent time span in weeks.
3979
+ * @example
3980
+ * const ts = new TimeSpan(14, 'd');
3981
+ * ts.weeks(); // Returns 2
3907
3982
  */
3908
- stringify(value, space) {
3909
- if (this.pure) {
3910
- return JSON.stringify(value, void 0, space);
3911
- }
3912
- return JSON.stringify(this.encode(value), void 0, space);
3983
+ weeks() {
3984
+ return this.milliseconds() / UNIT_TO_MS.w;
3913
3985
  }
3914
3986
  /**
3915
- * Parses a JSON string using custom decoding logic.
3916
- * @param {string} value - The JSON string to parse.
3917
- * @returns {any} - The decoded JavaScript object.
3987
+ * Adds a specified value and unit to the current time span.
3988
+ *
3989
+ * Returns new instance.
3990
+ *
3991
+ * @param {number} value - The value to add.
3992
+ * @param {TimeSpanUnit} [unit='ms'] - The unit of the value to add (default is milliseconds).
3993
+ * @returns {TimeSpan} A new TimeSpan instance with the added value.
3994
+ * @example
3995
+ * const ts = new TimeSpan(1, 'h');
3996
+ * ts.add(30, 'm'); // Represents 1.5 hours
3918
3997
  */
3919
- parse(value) {
3920
- if (this.pure) {
3921
- return JSON.parse(value);
3922
- }
3923
- return JSON.parse(value, this.reviewerReady);
3998
+ add(value, unit = "ms") {
3999
+ const multiplier = UNIT_TO_MS[unit];
4000
+ return new TimeSpan(this.milliseconds() + value * multiplier, "ms");
3924
4001
  }
3925
- /** @internal */
3926
- _replacer(value, key) {
3927
- if (isPlainObject(value)) return;
3928
- if (Array.isArray(value)) return;
3929
- if (!isInfinity(value) && !isBigInt(value)) {
3930
- if (isPrimitive(value)) return;
3931
- }
3932
- for (const type of this.typeHandlers.values()) {
3933
- const res = type.encode(value, this.encode);
3934
- if (res !== void 0) {
3935
- return type.encodeInline ? res : { [type.placeholder]: res };
3936
- }
3937
- }
3938
- return value;
4002
+ /**
4003
+ * Subtracts a specified value and unit from the current time span.
4004
+ *
4005
+ * Returns new instance.
4006
+ *
4007
+ * @param {number} value - The value to subtract.
4008
+ * @param {TimeSpanUnit} [unit='ms'] - The unit of the value to subtract (default is milliseconds).
4009
+ * @returns {TimeSpan} A new TimeSpan instance with the subtracted value.
4010
+ * @example
4011
+ * const ts = new TimeSpan(1, 'h');
4012
+ * ts.subtract(30, 'm'); // Represents 30 minutes less than 1 hour
4013
+ */
4014
+ subtract(value, unit = "ms") {
4015
+ const multiplier = UNIT_TO_MS[unit];
4016
+ return new TimeSpan(this.milliseconds() - value * multiplier, "ms");
3939
4017
  }
3940
- /** @internal */
3941
- _reviewer(_, value) {
3942
- const key = firstKey(value);
3943
- if (!key || key[0] !== "$") return value;
3944
- const type = this.typeHandlers.get(key);
3945
- if (type) {
3946
- return type.decode(value[key]);
3947
- }
3948
- return value;
4018
+ }
4019
+
4020
+ function createTimeSpan(value, unit = "ms") {
4021
+ return new TimeSpan(value, unit);
4022
+ }
4023
+
4024
+ function timestampMs(fromValue = Date.now()) {
4025
+ if (isDate(fromValue)) {
4026
+ fromValue = fromValue.getTime();
4027
+ } else if (isString(fromValue)) {
4028
+ const dt = new Date(fromValue);
4029
+ fromValue = isDate(dt) ? dt.getTime() : 0;
3949
4030
  }
4031
+ return isNumber(fromValue) ? fromValue : 0;
3950
4032
  }
3951
- function firstKey(value) {
3952
- if (!isObject(value)) return null;
3953
- for (const key in value) {
3954
- return key;
4033
+
4034
+ function dateInDays(days, fromValue = Date.now()) {
4035
+ return new Date(timestampMs(fromValue) + days * 60 * 60 * 24 * 1e3);
4036
+ }
4037
+
4038
+ function dateInSeconds(seconds, fromValue = Date.now()) {
4039
+ return new Date(timestampMs(fromValue) + seconds * 1e3);
4040
+ }
4041
+
4042
+ function getRandomTime(startTime = { h: 0, m: 0 }, endTime = { h: 23, m: 59 }) {
4043
+ const h = getRandomInt(startTime.h, endTime.h);
4044
+ if (startTime.h === endTime.h) {
4045
+ return { h, m: getRandomInt(startTime.m, endTime.m) };
3955
4046
  }
3956
- return null;
4047
+ if (h === startTime.h) {
4048
+ return { h, m: getRandomInt(startTime.m, 59) };
4049
+ }
4050
+ if (h === endTime.h) {
4051
+ return { h, m: getRandomInt(0, endTime.m) };
4052
+ }
4053
+ return { h, m: getRandomInt(0, 59) };
4054
+ }
4055
+
4056
+ function hmToSeconds(hm) {
4057
+ hm = Number(hm);
4058
+ number$1(hm, "expected number value");
4059
+ const h = Math.floor(hm);
4060
+ const m = round2digits(hm - h) * 100;
4061
+ return h * 3600 + m * 60;
4062
+ }
4063
+
4064
+ function isTimeString(value) {
4065
+ if (!isString(value)) return false;
4066
+ const parts = value.split(":").map(Number);
4067
+ if (parts.length !== 2) return false;
4068
+ const [h, m] = parts;
4069
+ return h >= 0 && h < 24 && m >= 0 && m < 60;
3957
4070
  }
3958
4071
 
3959
- function createEJSON(withBasicTypes = false) {
3960
- const ejson = new EJSON();
3961
- if (withBasicTypes) {
3962
- ejson.addType(MapType);
3963
- ejson.addType(SetType);
3964
- ejson.addType(DateType);
3965
- ejson.addType(InfinityType);
3966
- ejson.addType(BigIntType);
3967
- ejson.addType(BinaryType);
3968
- ejson.addType(RegexType);
3969
- }
3970
- return ejson;
4072
+ function isTimeValue(value) {
4073
+ return isTimeString(value) || isTimeObject(value);
3971
4074
  }
3972
4075
 
3973
- class EJSONStream extends TransformStream {
3974
- ejson;
3975
- constructor({ ejson, cl, op, sep, onFlush, onStart }) {
3976
- let firstChunk = true;
3977
- super({
3978
- start(controller) {
3979
- return Promise.resolve().then(() => {
3980
- if (onStart) {
3981
- return onStart(controller);
3982
- }
3983
- }).then(() => {
3984
- controller.enqueue(op);
3985
- });
3986
- },
3987
- transform(chunk, controller) {
3988
- const jsonString = ejson.stringify(chunk);
3989
- if (firstChunk) {
3990
- firstChunk = false;
3991
- } else {
3992
- controller.enqueue(sep);
3993
- }
3994
- controller.enqueue(jsonString);
3995
- },
3996
- flush(controller) {
3997
- controller.enqueue(cl);
3998
- if (onFlush) {
3999
- return onFlush(controller);
4000
- }
4001
- }
4002
- });
4003
- this.ejson = ejson;
4076
+ function isValidWeekDay(value) {
4077
+ return isNumber(value) && Number.isInteger(value) && value >= 1 && value <= 7;
4078
+ }
4079
+
4080
+ function secondsToHm(seconds) {
4081
+ const value = Number(seconds);
4082
+ number$1(value, "expected number value");
4083
+ const h = Math.floor(value / 3600);
4084
+ const m = Math.floor(value % 3600 / 60);
4085
+ return round2digits(h + m / 100, 2);
4086
+ }
4087
+
4088
+ function timeFromMinutes(value, returnsNullWhenInvalid = false) {
4089
+ if (!isNumber(value)) {
4090
+ ok(
4091
+ returnsNullWhenInvalid,
4092
+ "Failed to time parse from minutes: " + value
4093
+ );
4094
+ return null;
4004
4095
  }
4005
- /**
4006
- * The vendor name used for the custom MIME type definition.
4007
- * If null, defaults to 'application/json'.
4008
- */
4009
- get vendorName() {
4010
- return this.ejson.vendorName;
4096
+ if (value === 0) {
4097
+ return { h: 0, m: 0 };
4011
4098
  }
4012
- /**
4013
- * MIME type based on the provided vendor name or defaults to 'application/json'.
4014
- */
4015
- get mimetype() {
4016
- return this.ejson.mimetype;
4099
+ value = value % 1440;
4100
+ if (value < 0) {
4101
+ value += 1440;
4017
4102
  }
4103
+ const h = Math.floor(value / 60);
4104
+ const m = value % 60;
4105
+ return { h, m };
4018
4106
  }
4019
4107
 
4020
- const instance = createEJSON(true);
4108
+ function timestampToDate(value) {
4109
+ if (!isNumber(value)) return null;
4110
+ return new Date(value * 1e3);
4111
+ }
4021
4112
 
4022
- function createEJSONStream(options = {}) {
4023
- if (options.resultKey || options.append || options.prepend) {
4024
- return createEJSONStreamPayload(options);
4113
+ function timeStringify(value, returnsNullWhenInvalid = false) {
4114
+ const timeObject = createTimeObject(value, true);
4115
+ if (!timeObject) {
4116
+ ok(
4117
+ returnsNullWhenInvalid,
4118
+ "Failed to stringify time from: " + JSON.stringify(value)
4119
+ );
4120
+ return null;
4025
4121
  }
4026
- return new EJSONStream(getOptions(options));
4122
+ let { h, m } = timeObject;
4123
+ const hStr = Math.ceil(h).toString().padStart(2, "0").slice(-2);
4124
+ const mStr = Math.ceil(m).toString().padStart(2, "0").slice(-2);
4125
+ return `${hStr}:${mStr}`;
4027
4126
  }
4028
- function createEJSONStreamPayload(options) {
4029
- let { cl, ejson, op, sep } = getOptions(options);
4030
- const { append, prepend, resultKey } = options;
4031
- notEmptyString(resultKey, "resultKey required.");
4032
- const stream = new EJSONStream({
4033
- ejson,
4034
- cl,
4035
- op,
4036
- sep,
4037
- onStart(controller) {
4038
- if (!prepend) {
4039
- controller.enqueue(`{"${resultKey}":`);
4040
- return Promise.resolve();
4041
- }
4042
- return Promise.resolve().then(() => prepend()).then((data) => {
4043
- if (data === null || data === void 0) {
4044
- controller.enqueue(`{"${resultKey}":`);
4045
- return;
4046
- }
4047
- ok(
4048
- isPlainObject(data),
4049
- "prepend result expected to be plain object"
4050
- );
4051
- const dataPart = instance.stringify(data).slice(0, -1);
4052
- if (dataPart === "{") {
4053
- controller.enqueue(`{"${resultKey}":`);
4054
- return;
4055
- }
4056
- controller.enqueue(`${dataPart}${sep}"${resultKey}":`);
4057
- });
4058
- },
4059
- onFlush(controller) {
4060
- if (!append) {
4061
- controller.enqueue("}");
4062
- return Promise.resolve();
4063
- }
4064
- return Promise.resolve().then(() => append()).then((data) => {
4065
- if (data === null || data === void 0) {
4066
- controller.enqueue("}");
4067
- return;
4068
- }
4069
- ok(
4070
- isPlainObject(data),
4071
- "prepend result expected to be plain object"
4072
- );
4073
- const dataPart = instance.stringify(data).slice(1);
4074
- if (dataPart === "}") {
4075
- controller.enqueue(`}`);
4076
- return;
4077
- }
4078
- controller.enqueue(`${sep}${dataPart}`);
4079
- });
4080
- }
4081
- });
4082
- return stream;
4127
+
4128
+ function timeToMinutes(value) {
4129
+ const time = createTimeObject(value);
4130
+ return time.h * 60 + time.m;
4083
4131
  }
4084
- function getOptions(options) {
4085
- const { ejson = instance, cl = "]", op = "[", sep = "," } = options;
4086
- return {
4087
- cl,
4088
- ejson,
4089
- op,
4090
- sep
4091
- };
4132
+
4133
+ function weeksInYear(year) {
4134
+ const target = new Date(Date.UTC(year + 1, 0, 1));
4135
+ const dayNumber = target.getDay();
4136
+ return dayNumber < 4 ? 52 : 53;
4092
4137
  }
4093
4138
 
4094
4139
  const env = (() => {
@@ -4153,7 +4198,7 @@ function createEnvParser(targetObject) {
4153
4198
  return defaultValue;
4154
4199
  }
4155
4200
  try {
4156
- return JSON.parse(targetObject[key]);
4201
+ return instance.parse(targetObject[key]);
4157
4202
  } catch (err) {
4158
4203
  console.warn("Failed to parse json env variable", key);
4159
4204
  return defaultValue;
@@ -4761,28 +4806,6 @@ const logger = (...baseArgs) => {
4761
4806
  return instance;
4762
4807
  };
4763
4808
 
4764
- function asyncFilter(array, predicate) {
4765
- var i = 0;
4766
- var result = [];
4767
- var cooldown = nextTickIteration(10);
4768
- return new Promise((resolve, reject) => {
4769
- var processNextBatch = () => {
4770
- if (i < array.length) {
4771
- cooldown().then(() => predicate(array[i], i, array)).then((valid) => {
4772
- if (Boolean(valid)) {
4773
- result.push(array[i]);
4774
- }
4775
- i++;
4776
- setTimeout(processNextBatch, 0);
4777
- }).catch(reject);
4778
- } else {
4779
- resolve(result);
4780
- }
4781
- };
4782
- processNextBatch();
4783
- });
4784
- }
4785
-
4786
4809
  function nextTickIteration(amount, delay = "tick") {
4787
4810
  let counter = 0;
4788
4811
  const tickInterval = delay === "tick";
@@ -4802,6 +4825,45 @@ function nextTickIteration(amount, delay = "tick") {
4802
4825
  };
4803
4826
  }
4804
4827
 
4828
+ function asyncFilter(array, predicate, { concurrency = 1 } = {}) {
4829
+ concurrency = Math.max(concurrency, 1);
4830
+ if (array.length === 0) {
4831
+ return Promise.resolve([]);
4832
+ }
4833
+ var result = [];
4834
+ var currentIndex = 0;
4835
+ var completed = 0;
4836
+ var hasError = false;
4837
+ var cooldown = nextTickIteration(10);
4838
+ return new Promise((resolve, reject) => {
4839
+ var processItem = (index) => {
4840
+ if (hasError || index >= array.length) return;
4841
+ cooldown().then(() => predicate(array[index], index, array)).then((include) => {
4842
+ if (hasError) return;
4843
+ if (include) {
4844
+ result.push(index);
4845
+ }
4846
+ completed++;
4847
+ if (completed >= array.length) {
4848
+ resolve(result.toSorted((a, b) => a - b).map((idx) => array[idx]));
4849
+ } else {
4850
+ if (currentIndex < array.length) {
4851
+ processItem(currentIndex++);
4852
+ }
4853
+ }
4854
+ }).catch((error) => {
4855
+ if (!hasError) {
4856
+ hasError = true;
4857
+ reject(error);
4858
+ }
4859
+ });
4860
+ };
4861
+ for (; currentIndex < concurrency; currentIndex++) {
4862
+ processItem(currentIndex);
4863
+ }
4864
+ });
4865
+ }
4866
+
4805
4867
  function asyncFind(array, callbackfn) {
4806
4868
  var i = 0;
4807
4869
  var cooldown = nextTickIteration(10);
@@ -4826,35 +4888,36 @@ function asyncFind(array, callbackfn) {
4826
4888
 
4827
4889
  function asyncForEach(array, callbackfn, { concurrency = 1 } = {}) {
4828
4890
  concurrency = Math.max(concurrency, 1);
4829
- var i = 0;
4891
+ if (array.length === 0) {
4892
+ return Promise.resolve();
4893
+ }
4894
+ var hasError = false;
4895
+ var completed = 0;
4896
+ var currentIndex = 0;
4830
4897
  var cooldown = nextTickIteration(10);
4831
- var tasks = Array(concurrency);
4832
4898
  return new Promise((resolve, reject) => {
4833
- var processNextBatch = () => {
4834
- if (i >= array.length) {
4835
- resolve();
4836
- return;
4837
- }
4838
- cooldown().then(() => {
4839
- for (var idx = 0; idx < concurrency; idx++) {
4840
- tasks[idx] = Promise.resolve(i);
4841
- if (i < array.length) {
4842
- tasks[idx] = tasks[idx].then(
4843
- (itemIndex) => callbackfn(array[itemIndex], itemIndex, array)
4844
- );
4899
+ var processItem = (index) => {
4900
+ if (hasError || index >= array.length) return;
4901
+ cooldown().then(() => callbackfn(array[index], index, array)).then((transformed) => {
4902
+ if (hasError) return;
4903
+ completed++;
4904
+ if (completed >= array.length) {
4905
+ resolve();
4906
+ } else {
4907
+ if (currentIndex < array.length) {
4908
+ processItem(currentIndex++);
4845
4909
  }
4846
- i++;
4847
4910
  }
4848
- return Promise.all(tasks);
4849
- }).then(() => {
4850
- if (i < array.length) {
4851
- setTimeout(processNextBatch, 0);
4852
- } else {
4853
- resolve();
4911
+ }).catch((error) => {
4912
+ if (!hasError) {
4913
+ hasError = true;
4914
+ reject(error);
4854
4915
  }
4855
- }).catch(reject);
4916
+ });
4856
4917
  };
4857
- processNextBatch();
4918
+ for (; currentIndex < concurrency; currentIndex++) {
4919
+ processItem(currentIndex);
4920
+ }
4858
4921
  });
4859
4922
  }
4860
4923
 
@@ -4995,38 +5058,38 @@ class AsyncIterableQueue {
4995
5058
 
4996
5059
  function asyncMap(array, callbackfn, { concurrency = 1 } = {}) {
4997
5060
  concurrency = Math.max(concurrency, 1);
4998
- var result = [];
4999
- var i = 0;
5061
+ if (array.length === 0) {
5062
+ return Promise.resolve([]);
5063
+ }
5064
+ var hasError = false;
5065
+ var result = Array(array.length);
5066
+ var completed = 0;
5067
+ var currentIndex = 0;
5000
5068
  var cooldown = nextTickIteration(10);
5001
- var tasks = Array(concurrency);
5002
5069
  return new Promise((resolve, reject) => {
5003
- var processNextBatch = () => {
5004
- if (i >= array.length) {
5005
- resolve(result);
5006
- } else {
5007
- cooldown().then(() => {
5008
- for (var idx = 0; idx < concurrency; idx++) {
5009
- tasks[idx] = Promise.resolve(i);
5010
- if (i < array.length) {
5011
- tasks[idx] = tasks[idx].then(
5012
- (itemIndex) => callbackfn(array[itemIndex], itemIndex, array)
5013
- ).then((transformed) => {
5014
- result.push(transformed);
5015
- });
5016
- }
5017
- i++;
5018
- }
5019
- return Promise.all(tasks);
5020
- }).then(() => {
5021
- if (i < array.length) {
5022
- setTimeout(processNextBatch, 0);
5023
- } else {
5024
- resolve(result);
5070
+ var processItem = (index) => {
5071
+ if (hasError || index >= array.length) return;
5072
+ cooldown().then(() => callbackfn(array[index], index, array)).then((transformed) => {
5073
+ if (hasError) return;
5074
+ result[index] = transformed;
5075
+ completed++;
5076
+ if (completed >= array.length) {
5077
+ resolve(result);
5078
+ } else {
5079
+ if (currentIndex < array.length) {
5080
+ processItem(currentIndex++);
5025
5081
  }
5026
- }).catch(reject);
5027
- }
5082
+ }
5083
+ }).catch((error) => {
5084
+ if (!hasError) {
5085
+ hasError = true;
5086
+ reject(error);
5087
+ }
5088
+ });
5028
5089
  };
5029
- processNextBatch();
5090
+ for (; currentIndex < concurrency; currentIndex++) {
5091
+ processItem(currentIndex);
5092
+ }
5030
5093
  });
5031
5094
  }
5032
5095
 
@@ -5470,6 +5533,60 @@ function timeout(ms, promiseOrCallback, timeoutError = new AppError(408)) {
5470
5533
  });
5471
5534
  }
5472
5535
 
5536
+ const stringifyArgs = (...args) => {
5537
+ return args.map((v) => argToKey(v, { objectStrategy: "json" })).join("_");
5538
+ };
5539
+ function withResolve(fn, getCacheKey) {
5540
+ const cache = /* @__PURE__ */ new Map();
5541
+ const cacheKeyVariants = arrayable(getCacheKey);
5542
+ return function(...args) {
5543
+ let cacheKey = stringifyArgs(...args);
5544
+ if (cacheKeyVariants?.length) {
5545
+ for (const getCacheKey2 of cacheKeyVariants) {
5546
+ const newCacheKey = getCacheKey2(args, stringifyArgs);
5547
+ if (newCacheKey === null) {
5548
+ cacheKey = Symbol();
5549
+ break;
5550
+ } else if (isString(newCacheKey) && cache.has(newCacheKey)) {
5551
+ cacheKey = newCacheKey;
5552
+ break;
5553
+ }
5554
+ }
5555
+ }
5556
+ const defers = cache.get(cacheKey) || [];
5557
+ const size = defers.length;
5558
+ const q = defer();
5559
+ defers.push(q);
5560
+ cache.set(cacheKey, defers);
5561
+ if (size) {
5562
+ return q.promise;
5563
+ }
5564
+ resolver(this, cacheKey, args);
5565
+ return q.promise;
5566
+ };
5567
+ function resolver(self, cacheKey, args) {
5568
+ const onSuccess = (r) => {
5569
+ const defers = cache.get(cacheKey) || [];
5570
+ for (const q of defers) {
5571
+ q.resolve(r);
5572
+ }
5573
+ cache.delete(cacheKey);
5574
+ };
5575
+ const onError = (r) => {
5576
+ const defers = cache.get(cacheKey) || [];
5577
+ for (const q of defers) {
5578
+ q.reject(r);
5579
+ }
5580
+ cache.delete(cacheKey);
5581
+ };
5582
+ try {
5583
+ fn.apply(self, args).then(onSuccess).catch(onError);
5584
+ } catch (err) {
5585
+ onError(err);
5586
+ }
5587
+ }
5588
+ }
5589
+
5473
5590
  exports.AppError = AppError;
5474
5591
  exports.AsyncIterableQueue = AsyncIterableQueue;
5475
5592
  exports.BrowserAssertionError = BrowserAssertionError;
@@ -5590,6 +5707,7 @@ exports.humanFileSize = humanFileSize;
5590
5707
  exports.humanize = humanize;
5591
5708
  exports.interpolateColor = interpolateColor;
5592
5709
  exports.intersection = intersection;
5710
+ exports.intersectionBy = intersectionBy;
5593
5711
  exports.isBigInt = isBigInt;
5594
5712
  exports.isBoolean = isBoolean;
5595
5713
  exports.isCached = isCached;
@@ -5605,6 +5723,7 @@ exports.isError = isError;
5605
5723
  exports.isFunction = isFunction;
5606
5724
  exports.isInfinity = isInfinity;
5607
5725
  exports.isMap = isMap;
5726
+ exports.isNode = isNode;
5608
5727
  exports.isNullOrUndefined = isNullOrUndefined;
5609
5728
  exports.isNumber = isNumber;
5610
5729
  exports.isObject = isObject;
@@ -5695,5 +5814,6 @@ exports.withCacheFixed = withCacheFixed;
5695
5814
  exports.withCacheLRU = withCacheLRU;
5696
5815
  exports.withDeepClone = withDeepClone;
5697
5816
  exports.withPointerCache = withPointerCache;
5817
+ exports.withResolve = withResolve;
5698
5818
  exports.wrapText = wrapText;
5699
5819
  //# sourceMappingURL=index.cjs.map