es-toolkit 1.13.1-dev.318 → 1.13.1-dev.321
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/array/chunk.mjs +1 -1
- package/dist/array/compact.mjs +1 -1
- package/dist/array/countBy.js +1 -2
- package/dist/array/countBy.js.map +1 -1
- package/dist/array/countBy.mjs +2 -2
- package/dist/array/difference.mjs +1 -1
- package/dist/array/differenceBy.mjs +1 -1
- package/dist/array/differenceWith.mjs +1 -1
- package/dist/array/drop.mjs +1 -1
- package/dist/array/dropRight.mjs +1 -1
- package/dist/array/dropRightWhile.mjs +1 -1
- package/dist/array/dropWhile.mjs +1 -1
- package/dist/array/fill.mjs +1 -1
- package/dist/array/flatMap.mjs +1 -1
- package/dist/array/flatten.mjs +1 -1
- package/dist/array/flattenDeep.mjs +1 -1
- package/dist/array/forEachRight.mjs +1 -1
- package/dist/array/groupBy.mjs +1 -1
- package/dist/array/head.mjs +1 -1
- package/dist/array/index.js +1 -2
- package/dist/array/index.js.map +1 -1
- package/dist/array/index.mjs +2 -2
- package/dist/array/initial.mjs +1 -1
- package/dist/array/intersection.mjs +1 -1
- package/dist/array/intersectionBy.mjs +1 -1
- package/dist/array/intersectionWith.mjs +1 -1
- package/dist/array/keyBy.mjs +1 -1
- package/dist/array/last.mjs +1 -1
- package/dist/array/maxBy.mjs +1 -1
- package/dist/array/minBy.mjs +1 -1
- package/dist/array/orderBy.mjs +1 -1
- package/dist/array/partition.mjs +1 -1
- package/dist/array/sample.mjs +1 -1
- package/dist/array/sampleSize.mjs +1 -1
- package/dist/array/shuffle.mjs +1 -1
- package/dist/array/tail.mjs +1 -1
- package/dist/array/take.mjs +1 -1
- package/dist/array/takeRight.mjs +1 -1
- package/dist/array/takeRightWhile.mjs +1 -1
- package/dist/array/takeWhile.mjs +1 -1
- package/dist/array/toFilled.mjs +1 -1
- package/dist/array/union.mjs +1 -1
- package/dist/array/unionBy.mjs +1 -1
- package/dist/array/unionWith.mjs +1 -1
- package/dist/array/uniq.mjs +1 -1
- package/dist/array/uniqBy.mjs +1 -1
- package/dist/array/uniqWith.mjs +1 -1
- package/dist/array/unzip.mjs +1 -1
- package/dist/array/unzipWith.mjs +1 -1
- package/dist/array/without.mjs +1 -1
- package/dist/array/xor.mjs +1 -1
- package/dist/array/xorBy.mjs +1 -1
- package/dist/array/xorWith.mjs +1 -1
- package/dist/array/zip.mjs +1 -1
- package/dist/array/zipObject.mjs +1 -1
- package/dist/array/zipWith.mjs +1 -1
- package/dist/browser.js +33 -58
- package/dist/browser.js.map +1 -1
- package/dist/browser.mjs +19 -17
- package/dist/browser.mjs.map +1 -1
- package/dist/{chunk-QXTNZR7B.mjs → chunk-3SBT6WDU.mjs} +2 -2
- package/dist/{chunk-O64NE2P4.mjs → chunk-4DFAGGIM.mjs} +3 -3
- package/dist/{chunk-O64NE2P4.mjs.map → chunk-4DFAGGIM.mjs.map} +1 -1
- package/dist/{chunk-Y5V7UAZZ.mjs → chunk-4ZES5T6V.mjs} +4 -4
- package/dist/{chunk-EYYZQFOP.mjs → chunk-ET33L3MQ.mjs} +2 -2
- package/dist/chunk-EZYYB34V.mjs +17 -0
- package/dist/{chunk-CVVZHOJX.mjs.map → chunk-EZYYB34V.mjs.map} +1 -1
- package/dist/{chunk-36ZJSTNA.mjs → chunk-IGM5IABU.mjs} +37 -24
- package/dist/chunk-IGM5IABU.mjs.map +1 -0
- package/dist/{chunk-F3WCQQET.mjs → chunk-IWXZI3QT.mjs} +2 -2
- package/dist/chunk-J5LGTIGS.mjs +10 -0
- package/dist/{chunk-5CPXZFCB.mjs → chunk-K5WL54BY.mjs} +2 -2
- package/dist/{chunk-5CPXZFCB.mjs.map → chunk-K5WL54BY.mjs.map} +1 -1
- package/dist/{chunk-3IP4JVLL.mjs → chunk-MSHSKENG.mjs} +3 -3
- package/dist/{chunk-3IP4JVLL.mjs.map → chunk-MSHSKENG.mjs.map} +1 -1
- package/dist/{chunk-WVQ7YVRK.mjs → chunk-OG2RLT5U.mjs} +2 -3
- package/dist/{chunk-WVQ7YVRK.mjs.map → chunk-OG2RLT5U.mjs.map} +1 -1
- package/dist/chunk-R6GLTTAB.mjs +9 -0
- package/dist/chunk-R6GLTTAB.mjs.map +1 -0
- package/dist/{chunk-5IKVJGHO.mjs → chunk-RTFTLCF3.mjs} +2 -2
- package/dist/chunk-SXFMQQ6F.mjs +9 -0
- package/dist/chunk-SXFMQQ6F.mjs.map +1 -0
- package/dist/{chunk-WFZXCGEG.mjs → chunk-YOPFSFTD.mjs} +2 -6
- package/dist/{chunk-WFZXCGEG.mjs.map → chunk-YOPFSFTD.mjs.map} +1 -1
- package/dist/chunk-YXD3AQAK.mjs +1 -0
- package/dist/{chunk-CRSKT4WW.mjs → chunk-Z7HWEOQX.mjs} +2 -3
- package/dist/{chunk-CRSKT4WW.mjs.map → chunk-Z7HWEOQX.mjs.map} +1 -1
- package/dist/chunk-ZPNX2QDE.mjs +13 -0
- package/dist/{chunk-IIDZ3KAJ.mjs.map → chunk-ZPNX2QDE.mjs.map} +1 -1
- package/dist/compat/index.d.mts +20 -1
- package/dist/compat/index.d.ts +20 -1
- package/dist/compat/index.js +35 -57
- package/dist/compat/index.js.map +1 -1
- package/dist/compat/index.mjs +30 -23
- package/dist/error/AbortError.mjs +1 -1
- package/dist/error/TimeoutError.mjs +1 -1
- package/dist/error/index.mjs +1 -1
- package/dist/function/after.mjs +1 -1
- package/dist/function/debounce.js +2 -2
- package/dist/function/debounce.js.map +1 -1
- package/dist/function/debounce.mjs +2 -2
- package/dist/function/index.js +2 -2
- package/dist/function/index.js.map +1 -1
- package/dist/function/index.mjs +2 -2
- package/dist/function/negate.mjs +1 -1
- package/dist/function/noop.mjs +1 -1
- package/dist/function/once.mjs +1 -1
- package/dist/function/throttle.mjs +1 -1
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +27 -53
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +30 -22
- package/dist/math/clamp.mjs +1 -1
- package/dist/math/inRange.mjs +1 -1
- package/dist/math/index.mjs +1 -1
- package/dist/math/mean.mjs +1 -1
- package/dist/math/meanBy.mjs +1 -1
- package/dist/math/random.mjs +1 -1
- package/dist/math/randomInt.mjs +1 -1
- package/dist/math/range.mjs +1 -1
- package/dist/math/round.mjs +1 -1
- package/dist/math/sum.mjs +1 -1
- package/dist/math/sumBy.mjs +1 -1
- package/dist/object/clone.mjs +1 -1
- package/dist/object/cloneDeep.js +1 -1
- package/dist/object/cloneDeep.js.map +1 -1
- package/dist/object/cloneDeep.mjs +2 -2
- package/dist/object/flattenObject.mjs +1 -1
- package/dist/object/index.js +2 -16
- package/dist/object/index.js.map +1 -1
- package/dist/object/index.mjs +3 -3
- package/dist/object/invert.mjs +1 -1
- package/dist/object/omit.js +1 -15
- package/dist/object/omit.js.map +1 -1
- package/dist/object/omit.mjs +2 -2
- package/dist/object/omitBy.mjs +1 -1
- package/dist/object/pick.mjs +1 -1
- package/dist/object/pickBy.mjs +1 -1
- package/dist/predicate/index.d.mts +2 -0
- package/dist/predicate/index.d.ts +2 -0
- package/dist/predicate/index.js +14 -0
- package/dist/predicate/index.js.map +1 -1
- package/dist/predicate/index.mjs +12 -4
- package/dist/predicate/isArrayLike.mjs +1 -1
- package/dist/predicate/isEqual.mjs +1 -1
- package/dist/predicate/isFunction.mjs +1 -1
- package/dist/predicate/isLength.mjs +1 -1
- package/dist/predicate/isNil.mjs +1 -1
- package/dist/predicate/isNotNil.mjs +1 -1
- package/dist/predicate/isNull.mjs +1 -1
- package/dist/predicate/isPlainObject.mjs +1 -1
- package/dist/predicate/isPrimitive.d.mts +17 -0
- package/dist/predicate/isPrimitive.d.ts +17 -0
- package/dist/predicate/isPrimitive.js +33 -0
- package/dist/predicate/isPrimitive.js.map +1 -0
- package/dist/predicate/isPrimitive.mjs +8 -0
- package/dist/predicate/isPrimitive.mjs.map +1 -0
- package/dist/predicate/isTypedArray.d.mts +19 -0
- package/dist/predicate/isTypedArray.d.ts +19 -0
- package/dist/predicate/isTypedArray.js +33 -0
- package/dist/predicate/isTypedArray.js.map +1 -0
- package/dist/predicate/isTypedArray.mjs +8 -0
- package/dist/predicate/isTypedArray.mjs.map +1 -0
- package/dist/predicate/isUndefined.mjs +1 -1
- package/dist/promise/delay.js +2 -2
- package/dist/promise/delay.js.map +1 -1
- package/dist/promise/delay.mjs +2 -2
- package/dist/promise/index.js +7 -31
- package/dist/promise/index.js.map +1 -1
- package/dist/promise/index.mjs +4 -4
- package/dist/promise/timeout.js +5 -27
- package/dist/promise/timeout.js.map +1 -1
- package/dist/promise/timeout.mjs +3 -3
- package/dist/promise/withTimeout.js +7 -31
- package/dist/promise/withTimeout.js.map +1 -1
- package/dist/promise/withTimeout.mjs +4 -4
- package/dist/string/camelCase.js +1 -2
- package/dist/string/camelCase.js.map +1 -1
- package/dist/string/camelCase.mjs +3 -3
- package/dist/string/capitalize.mjs +1 -1
- package/dist/string/index.js +1 -2
- package/dist/string/index.js.map +1 -1
- package/dist/string/index.mjs +11 -11
- package/dist/string/kebabCase.js +1 -2
- package/dist/string/kebabCase.js.map +1 -1
- package/dist/string/kebabCase.mjs +3 -3
- package/dist/string/lowerCase.js +1 -2
- package/dist/string/lowerCase.js.map +1 -1
- package/dist/string/lowerCase.mjs +3 -3
- package/dist/string/snakeCase.js +1 -2
- package/dist/string/snakeCase.js.map +1 -1
- package/dist/string/snakeCase.mjs +3 -3
- package/dist/string/startCase.js +1 -2
- package/dist/string/startCase.js.map +1 -1
- package/dist/string/startCase.mjs +3 -3
- package/package.json +1 -1
- package/umd/browser.global.js +1 -1
- package/dist/chunk-24FKGR6U.mjs +0 -47
- package/dist/chunk-36ZJSTNA.mjs.map +0 -1
- package/dist/chunk-CVVZHOJX.mjs +0 -22
- package/dist/chunk-IIDZ3KAJ.mjs +0 -18
- package/dist/chunk-U4JWMVQK.mjs +0 -1
- /package/dist/{chunk-QXTNZR7B.mjs.map → chunk-3SBT6WDU.mjs.map} +0 -0
- /package/dist/{chunk-Y5V7UAZZ.mjs.map → chunk-4ZES5T6V.mjs.map} +0 -0
- /package/dist/{chunk-EYYZQFOP.mjs.map → chunk-ET33L3MQ.mjs.map} +0 -0
- /package/dist/{chunk-F3WCQQET.mjs.map → chunk-IWXZI3QT.mjs.map} +0 -0
- /package/dist/{chunk-24FKGR6U.mjs.map → chunk-J5LGTIGS.mjs.map} +0 -0
- /package/dist/{chunk-5IKVJGHO.mjs.map → chunk-RTFTLCF3.mjs.map} +0 -0
- /package/dist/{chunk-U4JWMVQK.mjs.map → chunk-YXD3AQAK.mjs.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getWords
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-OG2RLT5U.mjs";
|
|
4
4
|
|
|
5
5
|
// src/string/lowerCase.ts
|
|
6
6
|
var lowerCase = (str) => {
|
|
@@ -11,4 +11,4 @@ var lowerCase = (str) => {
|
|
|
11
11
|
export {
|
|
12
12
|
lowerCase
|
|
13
13
|
};
|
|
14
|
-
//# sourceMappingURL=chunk-
|
|
14
|
+
//# sourceMappingURL=chunk-RTFTLCF3.mjs.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// src/predicate/isTypedArray.ts
|
|
2
|
+
function isTypedArray(x) {
|
|
3
|
+
return x instanceof Uint8Array || x instanceof Uint8ClampedArray || x instanceof Uint16Array || x instanceof Uint32Array || x instanceof BigUint64Array || x instanceof Int8Array || x instanceof Int16Array || x instanceof Int32Array || x instanceof BigInt64Array || x instanceof Float32Array || x instanceof Float64Array;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export {
|
|
7
|
+
isTypedArray
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=chunk-SXFMQQ6F.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/predicate/isTypedArray.ts"],"sourcesContent":["/**\n * Checks if a value is a TypedArray.\n * @param {unknown} x The value to check.\n * @returns {x is\n * | Uint8Array\n * | Uint8ClampedArray\n * | Uint16Array\n * | Uint32Array\n * | BigUint64Array\n * | Int8Array\n * | Int16Array\n * | Int32Array\n * | BigInt64Array\n * | Float32Array\n * | Float64Array} Returns true if `x` is a TypedArray, false otherwise.\n */\nexport function isTypedArray(\n x: unknown\n): x is\n | Uint8Array\n | Uint8ClampedArray\n | Uint16Array\n | Uint32Array\n | BigUint64Array\n | Int8Array\n | Int16Array\n | Int32Array\n | BigInt64Array\n | Float32Array\n | Float64Array {\n return (\n x instanceof Uint8Array ||\n x instanceof Uint8ClampedArray ||\n x instanceof Uint16Array ||\n x instanceof Uint32Array ||\n x instanceof BigUint64Array ||\n x instanceof Int8Array ||\n x instanceof Int16Array ||\n x instanceof Int32Array ||\n x instanceof BigInt64Array ||\n x instanceof Float32Array ||\n x instanceof Float64Array\n );\n}\n"],"mappings":";AAgBO,SAAS,aACd,GAYe;AACf,SACE,aAAa,cACb,aAAa,qBACb,aAAa,eACb,aAAa,eACb,aAAa,kBACb,aAAa,aACb,aAAa,cACb,aAAa,cACb,aAAa,iBACb,aAAa,gBACb,aAAa;AAEjB;","names":[]}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__spreadValues
|
|
3
|
-
} from "./chunk-24FKGR6U.mjs";
|
|
4
|
-
|
|
5
1
|
// src/object/omit.ts
|
|
6
2
|
function omit(obj, keys) {
|
|
7
|
-
const result =
|
|
3
|
+
const result = { ...obj };
|
|
8
4
|
for (const key of keys) {
|
|
9
5
|
delete result[key];
|
|
10
6
|
}
|
|
@@ -14,4 +10,4 @@ function omit(obj, keys) {
|
|
|
14
10
|
export {
|
|
15
11
|
omit
|
|
16
12
|
};
|
|
17
|
-
//# sourceMappingURL=chunk-
|
|
13
|
+
//# sourceMappingURL=chunk-YOPFSFTD.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/object/omit.ts"],"sourcesContent":["/**\n * Creates a new object with specified keys omitted.\n *\n * This function takes an object and an array of keys, and returns a new object that\n * excludes the properties corresponding to the specified keys.\n *\n * @template T - The type of object.\n * @template K - The type of keys in object.\n * @param {T} obj - The object to omit keys from.\n * @param {K[]} keys - An array of keys to be omitted from the object.\n * @returns {Omit<T, K>} A new object with the specified keys omitted.\n *\n * @example\n * const obj = { a: 1, b: 2, c: 3 };\n * const result = omit(obj, ['b', 'c']);\n * // result will be { a: 1 }\n */\nexport function omit<T extends Record<string, any>, K extends keyof T>(obj: T, keys: K[]): Omit<T, K> {\n const result = { ...obj };\n\n for (const key of keys) {\n delete result[key];\n }\n\n return result as Omit<T, K>;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/object/omit.ts"],"sourcesContent":["/**\n * Creates a new object with specified keys omitted.\n *\n * This function takes an object and an array of keys, and returns a new object that\n * excludes the properties corresponding to the specified keys.\n *\n * @template T - The type of object.\n * @template K - The type of keys in object.\n * @param {T} obj - The object to omit keys from.\n * @param {K[]} keys - An array of keys to be omitted from the object.\n * @returns {Omit<T, K>} A new object with the specified keys omitted.\n *\n * @example\n * const obj = { a: 1, b: 2, c: 3 };\n * const result = omit(obj, ['b', 'c']);\n * // result will be { a: 1 }\n */\nexport function omit<T extends Record<string, any>, K extends keyof T>(obj: T, keys: K[]): Omit<T, K> {\n const result = { ...obj };\n\n for (const key of keys) {\n delete result[key];\n }\n\n return result as Omit<T, K>;\n}\n"],"mappings":";AAiBO,SAAS,KAAuD,KAAQ,MAAuB;AACpG,QAAM,SAAS,EAAE,GAAG,IAAI;AAExB,aAAW,OAAO,MAAM;AACtB,WAAO,OAAO,GAAG;AAAA,EACnB;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-YXD3AQAK.mjs.map
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
// src/array/countBy.ts
|
|
2
2
|
function countBy(arr, mapper) {
|
|
3
|
-
var _a;
|
|
4
3
|
const result = {};
|
|
5
4
|
for (const item of arr) {
|
|
6
5
|
const key = mapper(item);
|
|
7
|
-
result[key] = (
|
|
6
|
+
result[key] = (result[key] ?? 0) + 1;
|
|
8
7
|
}
|
|
9
8
|
return result;
|
|
10
9
|
}
|
|
@@ -12,4 +11,4 @@ function countBy(arr, mapper) {
|
|
|
12
11
|
export {
|
|
13
12
|
countBy
|
|
14
13
|
};
|
|
15
|
-
//# sourceMappingURL=chunk-
|
|
14
|
+
//# sourceMappingURL=chunk-Z7HWEOQX.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/array/countBy.ts"],"sourcesContent":["/**\n * Count the occurrences of each item in an array\n * based on a transformation function.\n *\n * This function takes an array and a transformation function\n * that converts each item in the array to a string. It then\n * counts the occurrences of each transformed item and returns\n * an object with the transformed items as keys and the counts\n * as values.\n *\n * @template T - The type of the items in the input array.\n *\n * @param {T[]} arr - The input array to count occurrences.\n * @param {(item: T) => string} mapper - The transformation function that maps each item to a string key.\n * @returns {Record<string, number>} An object containing the transformed items as keys and the\n * counts as values.\n */\nexport function countBy<T>(arr: T[], mapper: (item: T) => string): Record<string, number> {\n const result: Record<string, number> = {};\n \n for (const item of arr) {\n const key = mapper(item);\n \n result[key] = (result[key] ?? 0) + 1;\n }\n \n return result;\n}\n"],"mappings":";AAiBO,SAAS,QAAW,KAAU,QAAqD;
|
|
1
|
+
{"version":3,"sources":["../src/array/countBy.ts"],"sourcesContent":["/**\n * Count the occurrences of each item in an array\n * based on a transformation function.\n *\n * This function takes an array and a transformation function\n * that converts each item in the array to a string. It then\n * counts the occurrences of each transformed item and returns\n * an object with the transformed items as keys and the counts\n * as values.\n *\n * @template T - The type of the items in the input array.\n *\n * @param {T[]} arr - The input array to count occurrences.\n * @param {(item: T) => string} mapper - The transformation function that maps each item to a string key.\n * @returns {Record<string, number>} An object containing the transformed items as keys and the\n * counts as values.\n */\nexport function countBy<T>(arr: T[], mapper: (item: T) => string): Record<string, number> {\n const result: Record<string, number> = {};\n \n for (const item of arr) {\n const key = mapper(item);\n \n result[key] = (result[key] ?? 0) + 1;\n }\n \n return result;\n}\n"],"mappings":";AAiBO,SAAS,QAAW,KAAU,QAAqD;AACxF,QAAM,SAAiC,CAAC;AAExC,aAAW,QAAQ,KAAK;AACtB,UAAM,MAAM,OAAO,IAAI;AAEvB,WAAO,GAAG,KAAK,OAAO,GAAG,KAAK,KAAK;AAAA,EACrC;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
timeout
|
|
3
|
+
} from "./chunk-EZYYB34V.mjs";
|
|
4
|
+
|
|
5
|
+
// src/promise/withTimeout.ts
|
|
6
|
+
async function withTimeout(run, ms) {
|
|
7
|
+
return Promise.race([run(), timeout(ms)]);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
withTimeout
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=chunk-ZPNX2QDE.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/promise/withTimeout.ts"],"sourcesContent":["import { timeout } from './timeout.ts';\n\n/**\n * Executes an async function and enforces a timeout. \n * \n * If the promise does not resolve within the specified time,\n * the timeout will trigger and the returned promise will be rejected.\n *\n *\n * @template T \n * @param {() => Promise<T>} run - A function that returns a promise to be executed.\n * @param {number} ms - The timeout duration in milliseconds.\n * @returns {Promise<T>} A promise that resolves with the result of the `run` function or rejects if the timeout is reached.\n *\n * @example\n * try {\n * await withTimeout(() => {}, 1000); // Timeout exception after 1 second\n * } catch (error) {\n * console.error(error); // Will log 'TimeoutError'\n * }\n */\nexport async function withTimeout<T>(run: () => Promise<T>, ms: number): Promise<T> {\n return Promise.race([run(), timeout(ms) as T]);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/promise/withTimeout.ts"],"sourcesContent":["import { timeout } from './timeout.ts';\n\n/**\n * Executes an async function and enforces a timeout. \n * \n * If the promise does not resolve within the specified time,\n * the timeout will trigger and the returned promise will be rejected.\n *\n *\n * @template T \n * @param {() => Promise<T>} run - A function that returns a promise to be executed.\n * @param {number} ms - The timeout duration in milliseconds.\n * @returns {Promise<T>} A promise that resolves with the result of the `run` function or rejects if the timeout is reached.\n *\n * @example\n * try {\n * await withTimeout(() => {}, 1000); // Timeout exception after 1 second\n * } catch (error) {\n * console.error(error); // Will log 'TimeoutError'\n * }\n */\nexport async function withTimeout<T>(run: () => Promise<T>, ms: number): Promise<T> {\n return Promise.race([run(), timeout(ms) as T]);\n}\n"],"mappings":";;;;;AAqBA,eAAsB,YAAe,KAAuB,IAAwB;AAClF,SAAO,QAAQ,KAAK,CAAC,IAAI,GAAG,QAAQ,EAAE,CAAM,CAAC;AAC/C;","names":[]}
|
package/dist/compat/index.d.mts
CHANGED
|
@@ -80,6 +80,7 @@ export { isUndefined } from '../predicate/isUndefined.mjs';
|
|
|
80
80
|
export { isLength } from '../predicate/isLength.mjs';
|
|
81
81
|
export { isFunction } from '../predicate/isFunction.mjs';
|
|
82
82
|
export { isArrayLike } from '../predicate/isArrayLike.mjs';
|
|
83
|
+
export { isPrimitive } from '../predicate/isPrimitive.mjs';
|
|
83
84
|
export { delay } from '../promise/delay.mjs';
|
|
84
85
|
export { withTimeout } from '../promise/withTimeout.mjs';
|
|
85
86
|
export { camelCase } from '../string/camelCase.mjs';
|
|
@@ -540,6 +541,24 @@ declare function isPlainObject(object?: unknown): boolean;
|
|
|
540
541
|
*/
|
|
541
542
|
declare function isArray<T>(value?: T): value is Extract<T, readonly unknown[]>;
|
|
542
543
|
|
|
544
|
+
/**
|
|
545
|
+
* Checks if a value is a TypedArray.
|
|
546
|
+
* @param {unknown} x The value to check.
|
|
547
|
+
* @returns {x is
|
|
548
|
+
* | Uint8Array
|
|
549
|
+
* | Uint8ClampedArray
|
|
550
|
+
* | Uint16Array
|
|
551
|
+
* | Uint32Array
|
|
552
|
+
* | BigUint64Array
|
|
553
|
+
* | Int8Array
|
|
554
|
+
* | Int16Array
|
|
555
|
+
* | Int32Array
|
|
556
|
+
* | BigInt64Array
|
|
557
|
+
* | Float32Array
|
|
558
|
+
* | Float64Array} Returns true if `x` is a TypedArray, false otherwise.
|
|
559
|
+
*/
|
|
560
|
+
declare function isTypedArray(x?: unknown): x is Uint8Array | Uint8ClampedArray | Uint16Array | Uint32Array | BigUint64Array | Int8Array | Int16Array | Int32Array | BigInt64Array | Float32Array | Float64Array;
|
|
561
|
+
|
|
543
562
|
/**
|
|
544
563
|
* Checks if a string contains another string at the beginning of the string.
|
|
545
564
|
*
|
|
@@ -614,4 +633,4 @@ declare function min<T>(items: readonly [T, ...T[]]): T;
|
|
|
614
633
|
declare function min(): undefined;
|
|
615
634
|
declare function min<T>(items?: readonly T[]): T | undefined;
|
|
616
635
|
|
|
617
|
-
export { chunk, concat, difference, endsWith, fill, get, isArray, isPlainObject, max, min, set, startsWith, zipObjectDeep };
|
|
636
|
+
export { chunk, concat, difference, endsWith, fill, get, isArray, isPlainObject, isTypedArray, max, min, set, startsWith, zipObjectDeep };
|
package/dist/compat/index.d.ts
CHANGED
|
@@ -80,6 +80,7 @@ export { isUndefined } from '../predicate/isUndefined.js';
|
|
|
80
80
|
export { isLength } from '../predicate/isLength.js';
|
|
81
81
|
export { isFunction } from '../predicate/isFunction.js';
|
|
82
82
|
export { isArrayLike } from '../predicate/isArrayLike.js';
|
|
83
|
+
export { isPrimitive } from '../predicate/isPrimitive.js';
|
|
83
84
|
export { delay } from '../promise/delay.js';
|
|
84
85
|
export { withTimeout } from '../promise/withTimeout.js';
|
|
85
86
|
export { camelCase } from '../string/camelCase.js';
|
|
@@ -540,6 +541,24 @@ declare function isPlainObject(object?: unknown): boolean;
|
|
|
540
541
|
*/
|
|
541
542
|
declare function isArray<T>(value?: T): value is Extract<T, readonly unknown[]>;
|
|
542
543
|
|
|
544
|
+
/**
|
|
545
|
+
* Checks if a value is a TypedArray.
|
|
546
|
+
* @param {unknown} x The value to check.
|
|
547
|
+
* @returns {x is
|
|
548
|
+
* | Uint8Array
|
|
549
|
+
* | Uint8ClampedArray
|
|
550
|
+
* | Uint16Array
|
|
551
|
+
* | Uint32Array
|
|
552
|
+
* | BigUint64Array
|
|
553
|
+
* | Int8Array
|
|
554
|
+
* | Int16Array
|
|
555
|
+
* | Int32Array
|
|
556
|
+
* | BigInt64Array
|
|
557
|
+
* | Float32Array
|
|
558
|
+
* | Float64Array} Returns true if `x` is a TypedArray, false otherwise.
|
|
559
|
+
*/
|
|
560
|
+
declare function isTypedArray(x?: unknown): x is Uint8Array | Uint8ClampedArray | Uint16Array | Uint32Array | BigUint64Array | Int8Array | Int16Array | Int32Array | BigInt64Array | Float32Array | Float64Array;
|
|
561
|
+
|
|
543
562
|
/**
|
|
544
563
|
* Checks if a string contains another string at the beginning of the string.
|
|
545
564
|
*
|
|
@@ -614,4 +633,4 @@ declare function min<T>(items: readonly [T, ...T[]]): T;
|
|
|
614
633
|
declare function min(): undefined;
|
|
615
634
|
declare function min<T>(items?: readonly T[]): T | undefined;
|
|
616
635
|
|
|
617
|
-
export { chunk, concat, difference, endsWith, fill, get, isArray, isPlainObject, max, min, set, startsWith, zipObjectDeep };
|
|
636
|
+
export { chunk, concat, difference, endsWith, fill, get, isArray, isPlainObject, isTypedArray, max, min, set, startsWith, zipObjectDeep };
|
package/dist/compat/index.js
CHANGED
|
@@ -2,21 +2,7 @@
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
8
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
-
var __spreadValues = (a, b) => {
|
|
10
|
-
for (var prop in b || (b = {}))
|
|
11
|
-
if (__hasOwnProp.call(b, prop))
|
|
12
|
-
__defNormalProp(a, prop, b[prop]);
|
|
13
|
-
if (__getOwnPropSymbols)
|
|
14
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
15
|
-
if (__propIsEnum.call(b, prop))
|
|
16
|
-
__defNormalProp(a, prop, b[prop]);
|
|
17
|
-
}
|
|
18
|
-
return a;
|
|
19
|
-
};
|
|
20
6
|
var __export = (target, all) => {
|
|
21
7
|
for (var name in all)
|
|
22
8
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -30,26 +16,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
30
16
|
return to;
|
|
31
17
|
};
|
|
32
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
33
|
-
var __async = (__this, __arguments, generator) => {
|
|
34
|
-
return new Promise((resolve, reject) => {
|
|
35
|
-
var fulfilled = (value) => {
|
|
36
|
-
try {
|
|
37
|
-
step(generator.next(value));
|
|
38
|
-
} catch (e) {
|
|
39
|
-
reject(e);
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
var rejected = (value) => {
|
|
43
|
-
try {
|
|
44
|
-
step(generator.throw(value));
|
|
45
|
-
} catch (e) {
|
|
46
|
-
reject(e);
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
50
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
51
|
-
});
|
|
52
|
-
};
|
|
53
19
|
|
|
54
20
|
// src/compat/index.ts
|
|
55
21
|
var compat_exports = {};
|
|
@@ -101,6 +67,8 @@ __export(compat_exports, {
|
|
|
101
67
|
isNotNil: () => isNotNil,
|
|
102
68
|
isNull: () => isNull,
|
|
103
69
|
isPlainObject: () => isPlainObject2,
|
|
70
|
+
isPrimitive: () => isPrimitive3,
|
|
71
|
+
isTypedArray: () => isTypedArray3,
|
|
104
72
|
isUndefined: () => isUndefined,
|
|
105
73
|
kebabCase: () => kebabCase,
|
|
106
74
|
keyBy: () => keyBy,
|
|
@@ -189,11 +157,10 @@ function compact(arr) {
|
|
|
189
157
|
|
|
190
158
|
// src/array/countBy.ts
|
|
191
159
|
function countBy(arr, mapper) {
|
|
192
|
-
var _a;
|
|
193
160
|
const result = {};
|
|
194
161
|
for (const item of arr) {
|
|
195
162
|
const key = mapper(item);
|
|
196
|
-
result[key] = (
|
|
163
|
+
result[key] = (result[key] ?? 0) + 1;
|
|
197
164
|
}
|
|
198
165
|
return result;
|
|
199
166
|
}
|
|
@@ -724,7 +691,7 @@ function debounce(func, debounceMs, { signal } = {}) {
|
|
|
724
691
|
if (timeoutId !== null) {
|
|
725
692
|
clearTimeout(timeoutId);
|
|
726
693
|
}
|
|
727
|
-
if (signal
|
|
694
|
+
if (signal?.aborted) {
|
|
728
695
|
return;
|
|
729
696
|
}
|
|
730
697
|
timeoutId = setTimeout(() => {
|
|
@@ -741,7 +708,7 @@ function debounce(func, debounceMs, { signal } = {}) {
|
|
|
741
708
|
timeoutId = null;
|
|
742
709
|
}
|
|
743
710
|
};
|
|
744
|
-
signal
|
|
711
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
745
712
|
return debounced;
|
|
746
713
|
}
|
|
747
714
|
|
|
@@ -859,7 +826,7 @@ function range(start, end, step) {
|
|
|
859
826
|
|
|
860
827
|
// src/object/omit.ts
|
|
861
828
|
function omit(obj, keys) {
|
|
862
|
-
const result =
|
|
829
|
+
const result = { ...obj };
|
|
863
830
|
for (const key of keys) {
|
|
864
831
|
delete result[key];
|
|
865
832
|
}
|
|
@@ -1029,7 +996,7 @@ function cloneDeepHelper(obj, clonedObj) {
|
|
|
1029
996
|
for (const key in obj) {
|
|
1030
997
|
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
1031
998
|
const descriptor = Object.getOwnPropertyDescriptor(obj, key);
|
|
1032
|
-
if ((
|
|
999
|
+
if ((descriptor?.writable || descriptor?.set) && typeof descriptor?.value !== "function") {
|
|
1033
1000
|
clonedObj[key] = cloneDeep(obj[key]);
|
|
1034
1001
|
}
|
|
1035
1002
|
}
|
|
@@ -1154,6 +1121,16 @@ function isArrayLike(value) {
|
|
|
1154
1121
|
return value != null && typeof value !== "function" && isLength(value.length);
|
|
1155
1122
|
}
|
|
1156
1123
|
|
|
1124
|
+
// src/predicate/isTypedArray.ts
|
|
1125
|
+
function isTypedArray2(x) {
|
|
1126
|
+
return x instanceof Uint8Array || x instanceof Uint8ClampedArray || x instanceof Uint16Array || x instanceof Uint32Array || x instanceof BigUint64Array || x instanceof Int8Array || x instanceof Int16Array || x instanceof Int32Array || x instanceof BigInt64Array || x instanceof Float32Array || x instanceof Float64Array;
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
// src/predicate/isPrimitive.ts
|
|
1130
|
+
function isPrimitive3(value) {
|
|
1131
|
+
return value == null || typeof value !== "object" && typeof value !== "function";
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1157
1134
|
// src/promise/delay.ts
|
|
1158
1135
|
function delay(ms, { signal } = {}) {
|
|
1159
1136
|
return new Promise((resolve, reject) => {
|
|
@@ -1164,27 +1141,23 @@ function delay(ms, { signal } = {}) {
|
|
|
1164
1141
|
clearTimeout(timeoutId);
|
|
1165
1142
|
abortError();
|
|
1166
1143
|
};
|
|
1167
|
-
if (signal
|
|
1144
|
+
if (signal?.aborted) {
|
|
1168
1145
|
return abortError();
|
|
1169
1146
|
}
|
|
1170
1147
|
const timeoutId = setTimeout(resolve, ms);
|
|
1171
|
-
signal
|
|
1148
|
+
signal?.addEventListener("abort", abortHandler, { once: true });
|
|
1172
1149
|
});
|
|
1173
1150
|
}
|
|
1174
1151
|
|
|
1175
1152
|
// src/promise/timeout.ts
|
|
1176
|
-
function timeout(ms) {
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
throw new TimeoutError();
|
|
1180
|
-
});
|
|
1153
|
+
async function timeout(ms) {
|
|
1154
|
+
await delay(ms);
|
|
1155
|
+
throw new TimeoutError();
|
|
1181
1156
|
}
|
|
1182
1157
|
|
|
1183
1158
|
// src/promise/withTimeout.ts
|
|
1184
|
-
function withTimeout(run, ms) {
|
|
1185
|
-
return
|
|
1186
|
-
return Promise.race([run(), timeout(ms)]);
|
|
1187
|
-
});
|
|
1159
|
+
async function withTimeout(run, ms) {
|
|
1160
|
+
return Promise.race([run(), timeout(ms)]);
|
|
1188
1161
|
}
|
|
1189
1162
|
|
|
1190
1163
|
// src/string/capitalize.ts
|
|
@@ -1195,8 +1168,7 @@ var capitalize = (str) => {
|
|
|
1195
1168
|
// src/string/_internal/getWords.ts
|
|
1196
1169
|
var CASE_SPLIT_PATTERN = /[A-Z]?[a-z]+|[0-9]+|[A-Z]+(?![a-z])/g;
|
|
1197
1170
|
function getWords(str) {
|
|
1198
|
-
|
|
1199
|
-
return Array.from((_a = str.match(CASE_SPLIT_PATTERN)) != null ? _a : []);
|
|
1171
|
+
return Array.from(str.match(CASE_SPLIT_PATTERN) ?? []);
|
|
1200
1172
|
}
|
|
1201
1173
|
|
|
1202
1174
|
// src/string/camelCase.ts
|
|
@@ -1378,7 +1350,7 @@ function get(object, path, defaultValue) {
|
|
|
1378
1350
|
let resolvedPath;
|
|
1379
1351
|
if (Array.isArray(path)) {
|
|
1380
1352
|
resolvedPath = path;
|
|
1381
|
-
} else if (typeof path === "string" && isDeepKey(path) &&
|
|
1353
|
+
} else if (typeof path === "string" && isDeepKey(path) && object?.[path] == null) {
|
|
1382
1354
|
resolvedPath = toPath(path);
|
|
1383
1355
|
} else {
|
|
1384
1356
|
resolvedPath = [path];
|
|
@@ -1398,12 +1370,11 @@ function get(object, path, defaultValue) {
|
|
|
1398
1370
|
if (current === null && index === resolvedPath.length) {
|
|
1399
1371
|
return current;
|
|
1400
1372
|
}
|
|
1401
|
-
return current
|
|
1373
|
+
return current ?? defaultValue;
|
|
1402
1374
|
}
|
|
1403
1375
|
|
|
1404
1376
|
// src/compat/predicate/isPlainObject.ts
|
|
1405
1377
|
function isPlainObject2(object) {
|
|
1406
|
-
var _a;
|
|
1407
1378
|
if (typeof object !== "object") {
|
|
1408
1379
|
return false;
|
|
1409
1380
|
}
|
|
@@ -1418,7 +1389,7 @@ function isPlainObject2(object) {
|
|
|
1418
1389
|
if (tag == null) {
|
|
1419
1390
|
return false;
|
|
1420
1391
|
}
|
|
1421
|
-
const isTagReadonly = !
|
|
1392
|
+
const isTagReadonly = !Object.getOwnPropertyDescriptor(object, Symbol.toStringTag)?.writable;
|
|
1422
1393
|
if (isTagReadonly) {
|
|
1423
1394
|
return false;
|
|
1424
1395
|
}
|
|
@@ -1436,6 +1407,11 @@ function isArray(value) {
|
|
|
1436
1407
|
return Array.isArray(value);
|
|
1437
1408
|
}
|
|
1438
1409
|
|
|
1410
|
+
// src/compat/predicate/isTypedArray.ts
|
|
1411
|
+
function isTypedArray3(x) {
|
|
1412
|
+
return isTypedArray2(x);
|
|
1413
|
+
}
|
|
1414
|
+
|
|
1439
1415
|
// src/compat/string/startsWith.ts
|
|
1440
1416
|
var startsWith = (str, target, position = 0) => {
|
|
1441
1417
|
return str.startsWith(target, position);
|
|
@@ -1520,6 +1496,8 @@ function min(items = []) {
|
|
|
1520
1496
|
isNotNil,
|
|
1521
1497
|
isNull,
|
|
1522
1498
|
isPlainObject,
|
|
1499
|
+
isPrimitive,
|
|
1500
|
+
isTypedArray,
|
|
1523
1501
|
isUndefined,
|
|
1524
1502
|
kebabCase,
|
|
1525
1503
|
keyBy,
|