es-toolkit 1.10.1 → 1.11.0-dev.263
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/CHANGELOG.md +33 -0
- package/compat.d.ts +1 -0
- package/dist/array/chunk.mjs +1 -1
- package/dist/array/compact.mjs +1 -1
- package/dist/array/countBy.mjs +1 -1
- 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.js +1 -0
- package/dist/array/drop.js.map +1 -1
- package/dist/array/drop.mjs +2 -2
- package/dist/array/dropRight.js +5 -1
- package/dist/array/dropRight.js.map +1 -1
- package/dist/array/dropRight.mjs +2 -2
- package/dist/array/dropRightWhile.js +6 -14
- package/dist/array/dropRightWhile.js.map +1 -1
- package/dist/array/dropRightWhile.mjs +2 -3
- package/dist/array/dropWhile.mjs +1 -1
- package/dist/array/fill.d.mts +10 -7
- package/dist/array/fill.d.ts +10 -7
- package/dist/array/fill.js +7 -6
- package/dist/array/fill.js.map +1 -1
- package/dist/array/fill.mjs +2 -2
- package/dist/array/flatMap.d.mts +23 -0
- package/dist/array/flatMap.d.ts +23 -0
- package/dist/array/flatMap.js +52 -0
- package/dist/array/flatMap.js.map +1 -0
- package/dist/array/flatMap.mjs +9 -0
- 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.d.mts +1 -0
- package/dist/array/index.d.ts +1 -0
- package/dist/array/index.js +30 -14
- package/dist/array/index.js.map +1 -1
- package/dist/array/index.mjs +41 -37
- 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.d.mts +1 -1
- package/dist/array/uniqBy.d.ts +1 -1
- package/dist/array/uniqBy.js.map +1 -1
- package/dist/array/uniqBy.mjs +2 -2
- 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/{chunk-S3CORED5.mjs → chunk-3EZAFZG3.mjs} +2 -1
- package/dist/{chunk-S3CORED5.mjs.map → chunk-3EZAFZG3.mjs.map} +1 -1
- package/dist/{chunk-2MM5EJJX.mjs → chunk-424M7IR7.mjs} +23 -2
- package/dist/chunk-4OIZM4HS.mjs +1 -0
- package/dist/{chunk-GDC64SYJ.mjs → chunk-5ASRKEB4.mjs} +1 -1
- package/dist/{chunk-GDC64SYJ.mjs.map → chunk-5ASRKEB4.mjs.map} +1 -1
- package/dist/{chunk-OXAZEEGP.mjs → chunk-B4COTK4K.mjs} +1 -1
- package/dist/{chunk-OXAZEEGP.mjs.map → chunk-B4COTK4K.mjs.map} +1 -1
- package/dist/chunk-DDH7K4QM.mjs +1 -0
- package/dist/chunk-F47GLYUU.mjs +1 -0
- package/dist/chunk-J3GE7DEU.mjs +22 -0
- package/dist/chunk-J3GE7DEU.mjs.map +1 -0
- package/dist/chunk-KIOYQRMQ.mjs +12 -0
- package/dist/chunk-KIOYQRMQ.mjs.map +1 -0
- package/dist/chunk-M7SBBYV2.mjs +14 -0
- package/dist/chunk-M7SBBYV2.mjs.map +1 -0
- package/dist/{chunk-IZAD2S7R.mjs → chunk-MY4G7R3I.mjs} +2 -2
- package/dist/{chunk-74WWMNZS.mjs → chunk-OLX53VEF.mjs} +4 -2
- package/dist/{chunk-74WWMNZS.mjs.map → chunk-OLX53VEF.mjs.map} +1 -1
- package/dist/chunk-OXZCMC5I.mjs +13 -0
- package/dist/{chunk-JEKUA56R.mjs.map → chunk-OXZCMC5I.mjs.map} +1 -1
- package/dist/chunk-QXTNZR7B.mjs +25 -0
- package/dist/chunk-QXTNZR7B.mjs.map +1 -0
- package/dist/{chunk-QZITBKWX.mjs → chunk-U7V3G7CR.mjs} +2 -2
- package/dist/chunk-UY76KTPE.mjs +13 -0
- package/dist/chunk-UY76KTPE.mjs.map +1 -0
- package/dist/chunk-XT74R35S.mjs +1 -0
- package/dist/chunk-XT74R35S.mjs.map +1 -0
- package/dist/chunk-XWPCDIFC.mjs +18 -0
- package/dist/chunk-XWPCDIFC.mjs.map +1 -0
- package/dist/chunk-YFN6KOC4.mjs +15 -0
- package/dist/chunk-YFN6KOC4.mjs.map +1 -0
- package/dist/compat/index.d.mts +392 -1
- package/dist/compat/index.d.ts +392 -1
- package/dist/compat/index.js +276 -21
- package/dist/compat/index.js.map +1 -1
- package/dist/compat/index.mjs +268 -87
- package/dist/compat/index.mjs.map +1 -1
- package/dist/error/AbortError.mjs +1 -1
- package/dist/error/TimeoutError.d.mts +9 -0
- package/dist/error/TimeoutError.d.ts +9 -0
- package/dist/error/TimeoutError.js +36 -0
- package/dist/error/TimeoutError.js.map +1 -0
- package/dist/error/TimeoutError.mjs +8 -0
- package/dist/error/TimeoutError.mjs.map +1 -0
- package/dist/error/index.d.mts +1 -0
- package/dist/error/index.d.ts +1 -0
- package/dist/error/index.js +12 -2
- package/dist/error/index.js.map +1 -1
- package/dist/error/index.mjs +7 -3
- package/dist/function/debounce.mjs +1 -1
- package/dist/function/index.mjs +7 -7
- 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 +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +99 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +104 -87
- package/dist/math/clamp.mjs +1 -1
- package/dist/math/inRange.mjs +1 -1
- package/dist/math/index.js.map +1 -1
- package/dist/math/index.mjs +12 -12
- package/dist/math/mean.d.mts +1 -1
- package/dist/math/mean.d.ts +1 -1
- package/dist/math/mean.js.map +1 -1
- package/dist/math/mean.mjs +2 -2
- package/dist/math/meanBy.js.map +1 -1
- package/dist/math/meanBy.mjs +3 -3
- 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/index.js +3 -1
- package/dist/object/index.js.map +1 -1
- package/dist/object/index.mjs +6 -6
- package/dist/object/invert.js +3 -1
- package/dist/object/invert.js.map +1 -1
- package/dist/object/invert.mjs +2 -2
- 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.mjs +1 -1
- package/dist/predicate/isEqual.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/isUndefined.mjs +1 -1
- package/dist/promise/delay.mjs +1 -1
- package/dist/promise/index.d.mts +1 -0
- package/dist/promise/index.d.ts +1 -0
- package/dist/promise/index.js +47 -2
- package/dist/promise/index.js.map +1 -1
- package/dist/promise/index.mjs +9 -3
- package/dist/promise/timeout.d.mts +10 -0
- package/dist/promise/timeout.d.ts +10 -0
- package/dist/promise/timeout.js +92 -0
- package/dist/promise/timeout.js.map +1 -0
- package/dist/promise/timeout.mjs +11 -0
- package/dist/promise/timeout.mjs.map +1 -0
- package/dist/promise/withTimeout.d.mts +22 -0
- package/dist/promise/withTimeout.d.ts +22 -0
- package/dist/promise/withTimeout.js +99 -0
- package/dist/promise/withTimeout.js.map +1 -0
- package/dist/promise/withTimeout.mjs +12 -0
- package/dist/promise/withTimeout.mjs.map +1 -0
- package/dist/string/camelCase.mjs +1 -1
- package/dist/string/capitalize.mjs +1 -1
- package/dist/string/index.d.mts +1 -0
- package/dist/string/index.d.ts +1 -0
- package/dist/string/index.js +21 -2
- package/dist/string/index.js.map +1 -1
- package/dist/string/index.mjs +13 -9
- package/dist/string/kebabCase.mjs +1 -1
- package/dist/string/lowerCase.mjs +1 -1
- package/dist/string/snakeCase.mjs +1 -1
- package/dist/string/startCase.d.mts +16 -0
- package/dist/string/startCase.d.ts +16 -0
- package/dist/string/startCase.js +54 -0
- package/dist/string/startCase.js.map +1 -0
- package/dist/string/startCase.mjs +9 -0
- package/dist/string/startCase.mjs.map +1 -0
- package/package.json +3 -5
- package/dist/chunk-2MRZANXZ.mjs +0 -1
- package/dist/chunk-ARZ5BDR6.mjs +0 -1
- package/dist/chunk-C4WE4GLC.mjs +0 -14
- package/dist/chunk-C4WE4GLC.mjs.map +0 -1
- package/dist/chunk-FZEZH22H.mjs +0 -1
- package/dist/chunk-JE6JKZU3.mjs +0 -15
- package/dist/chunk-JE6JKZU3.mjs.map +0 -1
- package/dist/chunk-JEKUA56R.mjs +0 -9
- package/dist/chunk-QKYYOLJ6.mjs +0 -1
- /package/dist/{chunk-2MM5EJJX.mjs.map → array/flatMap.mjs.map} +0 -0
- /package/dist/{chunk-2MRZANXZ.mjs.map → chunk-424M7IR7.mjs.map} +0 -0
- /package/dist/{chunk-ARZ5BDR6.mjs.map → chunk-4OIZM4HS.mjs.map} +0 -0
- /package/dist/{chunk-FZEZH22H.mjs.map → chunk-DDH7K4QM.mjs.map} +0 -0
- /package/dist/{chunk-QKYYOLJ6.mjs.map → chunk-F47GLYUU.mjs.map} +0 -0
- /package/dist/{chunk-IZAD2S7R.mjs.map → chunk-MY4G7R3I.mjs.map} +0 -0
- /package/dist/{chunk-QZITBKWX.mjs.map → chunk-U7V3G7CR.mjs.map} +0 -0
package/dist/array/orderBy.mjs
CHANGED
package/dist/array/partition.mjs
CHANGED
package/dist/array/sample.mjs
CHANGED
package/dist/array/shuffle.mjs
CHANGED
package/dist/array/tail.mjs
CHANGED
package/dist/array/take.mjs
CHANGED
package/dist/array/takeRight.mjs
CHANGED
package/dist/array/takeWhile.mjs
CHANGED
package/dist/array/toFilled.mjs
CHANGED
package/dist/array/union.mjs
CHANGED
package/dist/array/unionBy.mjs
CHANGED
package/dist/array/unionWith.mjs
CHANGED
package/dist/array/uniq.mjs
CHANGED
package/dist/array/uniqBy.d.mts
CHANGED
package/dist/array/uniqBy.d.ts
CHANGED
package/dist/array/uniqBy.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/array/uniqBy.ts"],"sourcesContent":["/**\n * Returns a new array containing only the unique elements from the original array,\n * based on the values returned by the mapper function.\n *\n * @template T - The type of elements in the array.\n * @template U - The type of mapped elements.\n * @param {T[]} arr - The array to process.\n * @param {(item: T) => U} mapper - The function used to convert the array elements.\n * @returns {T[]} A new array containing only the unique elements from the original array, based on the values returned by the mapper function.\n *\n * @example\n * ```ts\n * uniqBy([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], Math.floor);\n * // [1.2, 2.1, 3.
|
|
1
|
+
{"version":3,"sources":["../../src/array/uniqBy.ts"],"sourcesContent":["/**\n * Returns a new array containing only the unique elements from the original array,\n * based on the values returned by the mapper function.\n *\n * @template T - The type of elements in the array.\n * @template U - The type of mapped elements.\n * @param {T[]} arr - The array to process.\n * @param {(item: T) => U} mapper - The function used to convert the array elements.\n * @returns {T[]} A new array containing only the unique elements from the original array, based on the values returned by the mapper function.\n *\n * @example\n * ```ts\n * uniqBy([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], Math.floor);\n * // [1.2, 2.1, 3.2, 5.7, 7.19]\n * ```\n */\nexport function uniqBy<T, U>(arr: readonly T[], mapper: (item: T) => U): T[] {\n const map = new Map<U, T>();\n\n for (const item of arr) {\n const key = mapper(item);\n\n if (!map.has(key)) {\n map.set(key, item);\n }\n }\n\n return Array.from(map.values());\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBO,SAAS,OAAa,KAAmB,QAA6B;AAC3E,QAAM,MAAM,oBAAI,IAAU;AAE1B,aAAW,QAAQ,KAAK;AACtB,UAAM,MAAM,OAAO,IAAI;AAEvB,QAAI,CAAC,IAAI,IAAI,GAAG,GAAG;AACjB,UAAI,IAAI,KAAK,IAAI;AAAA,IACnB;AAAA,EACF;AAEA,SAAO,MAAM,KAAK,IAAI,OAAO,CAAC;AAChC;","names":[]}
|
package/dist/array/uniqBy.mjs
CHANGED
package/dist/array/uniqWith.mjs
CHANGED
package/dist/array/unzip.mjs
CHANGED
package/dist/array/unzipWith.mjs
CHANGED
package/dist/array/without.mjs
CHANGED
package/dist/array/xor.mjs
CHANGED
package/dist/array/xorBy.mjs
CHANGED
package/dist/array/xorWith.mjs
CHANGED
package/dist/array/zip.mjs
CHANGED
package/dist/array/zipObject.mjs
CHANGED
package/dist/array/zipWith.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/array/drop.ts"],"sourcesContent":["/**\n * Removes a specified number of elements from the beginning of an array and returns the rest.\n *\n * This function takes an array and a number, and returns a new array with the specified number\n * of elements removed from the start.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array from which to drop elements.\n * @param {number} itemsCount - The number of elements to drop from the beginning of the array.\n * @returns {T[]} A new array with the specified number of elements removed from the start.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * const result = drop(array, 2);\n * // result will be [3, 4, 5] since the first two elements are dropped.\n */\nexport function drop<T>(arr: readonly T[], itemsCount: number): T[] {\n return arr.slice(itemsCount);\n}\n"],"mappings":";AAgBO,SAAS,KAAQ,KAAmB,YAAyB;AAClE,SAAO,IAAI,MAAM,UAAU;AAC7B;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/array/drop.ts"],"sourcesContent":["/**\n * Removes a specified number of elements from the beginning of an array and returns the rest.\n *\n * This function takes an array and a number, and returns a new array with the specified number\n * of elements removed from the start.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array from which to drop elements.\n * @param {number} itemsCount - The number of elements to drop from the beginning of the array.\n * @returns {T[]} A new array with the specified number of elements removed from the start.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * const result = drop(array, 2);\n * // result will be [3, 4, 5] since the first two elements are dropped.\n */\nexport function drop<T>(arr: readonly T[], itemsCount: number): T[] {\n itemsCount = Math.max(itemsCount, 0);\n\n return arr.slice(itemsCount);\n}\n"],"mappings":";AAgBO,SAAS,KAAQ,KAAmB,YAAyB;AAClE,eAAa,KAAK,IAAI,YAAY,CAAC;AAEnC,SAAO,IAAI,MAAM,UAAU;AAC7B;","names":[]}
|
|
@@ -14,8 +14,29 @@ var __spreadValues = (a, b) => {
|
|
|
14
14
|
}
|
|
15
15
|
return a;
|
|
16
16
|
};
|
|
17
|
+
var __async = (__this, __arguments, generator) => {
|
|
18
|
+
return new Promise((resolve, reject) => {
|
|
19
|
+
var fulfilled = (value) => {
|
|
20
|
+
try {
|
|
21
|
+
step(generator.next(value));
|
|
22
|
+
} catch (e) {
|
|
23
|
+
reject(e);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
var rejected = (value) => {
|
|
27
|
+
try {
|
|
28
|
+
step(generator.throw(value));
|
|
29
|
+
} catch (e) {
|
|
30
|
+
reject(e);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
34
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
35
|
+
});
|
|
36
|
+
};
|
|
17
37
|
|
|
18
38
|
export {
|
|
19
|
-
__spreadValues
|
|
39
|
+
__spreadValues,
|
|
40
|
+
__async
|
|
20
41
|
};
|
|
21
|
-
//# sourceMappingURL=chunk-
|
|
42
|
+
//# sourceMappingURL=chunk-424M7IR7.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-4OIZM4HS.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/math/mean.ts"],"sourcesContent":["import { sum } from './sum.ts';\n\n/**\n * Calculates the average of an array of numbers.\n *\n * If the array is empty, this function returns `NaN`.\n *\n * @param {number[]} nums - An array of numbers to calculate the average.\n * @returns {number} The average of all the numbers in the array.\n *\n * @example\n * const numbers = [1, 2, 3, 4, 5];\n * const result =
|
|
1
|
+
{"version":3,"sources":["../src/math/mean.ts"],"sourcesContent":["import { sum } from './sum.ts';\n\n/**\n * Calculates the average of an array of numbers.\n *\n * If the array is empty, this function returns `NaN`.\n *\n * @param {number[]} nums - An array of numbers to calculate the average.\n * @returns {number} The average of all the numbers in the array.\n *\n * @example\n * const numbers = [1, 2, 3, 4, 5];\n * const result = mean(numbers);\n * // result will be 3\n */\nexport function mean(nums: readonly number[]): number {\n return sum(nums) / nums.length;\n}\n"],"mappings":";;;;;AAeO,SAAS,KAAK,MAAiC;AACpD,SAAO,IAAI,IAAI,IAAI,KAAK;AAC1B;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/array/uniqBy.ts"],"sourcesContent":["/**\n * Returns a new array containing only the unique elements from the original array,\n * based on the values returned by the mapper function.\n *\n * @template T - The type of elements in the array.\n * @template U - The type of mapped elements.\n * @param {T[]} arr - The array to process.\n * @param {(item: T) => U} mapper - The function used to convert the array elements.\n * @returns {T[]} A new array containing only the unique elements from the original array, based on the values returned by the mapper function.\n *\n * @example\n * ```ts\n * uniqBy([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], Math.floor);\n * // [1.2, 2.1, 3.
|
|
1
|
+
{"version":3,"sources":["../src/array/uniqBy.ts"],"sourcesContent":["/**\n * Returns a new array containing only the unique elements from the original array,\n * based on the values returned by the mapper function.\n *\n * @template T - The type of elements in the array.\n * @template U - The type of mapped elements.\n * @param {T[]} arr - The array to process.\n * @param {(item: T) => U} mapper - The function used to convert the array elements.\n * @returns {T[]} A new array containing only the unique elements from the original array, based on the values returned by the mapper function.\n *\n * @example\n * ```ts\n * uniqBy([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], Math.floor);\n * // [1.2, 2.1, 3.2, 5.7, 7.19]\n * ```\n */\nexport function uniqBy<T, U>(arr: readonly T[], mapper: (item: T) => U): T[] {\n const map = new Map<U, T>();\n\n for (const item of arr) {\n const key = mapper(item);\n\n if (!map.has(key)) {\n map.set(key, item);\n }\n }\n\n return Array.from(map.values());\n}\n"],"mappings":";AAgBO,SAAS,OAAa,KAAmB,QAA6B;AAC3E,QAAM,MAAM,oBAAI,IAAU;AAE1B,aAAW,QAAQ,KAAK;AACtB,UAAM,MAAM,OAAO,IAAI;AAEvB,QAAI,CAAC,IAAI,IAAI,GAAG,GAAG;AACjB,UAAI,IAAI,KAAK,IAAI;AAAA,IACnB;AAAA,EACF;AAEA,SAAO,MAAM,KAAK,IAAI,OAAO,CAAC;AAChC;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-DDH7K4QM.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-F47GLYUU.mjs.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
delay
|
|
3
|
+
} from "./chunk-O64NE2P4.mjs";
|
|
4
|
+
import {
|
|
5
|
+
TimeoutError
|
|
6
|
+
} from "./chunk-KIOYQRMQ.mjs";
|
|
7
|
+
import {
|
|
8
|
+
__async
|
|
9
|
+
} from "./chunk-424M7IR7.mjs";
|
|
10
|
+
|
|
11
|
+
// src/promise/timeout.ts
|
|
12
|
+
function timeout(ms) {
|
|
13
|
+
return __async(this, null, function* () {
|
|
14
|
+
yield delay(ms);
|
|
15
|
+
throw new TimeoutError();
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export {
|
|
20
|
+
timeout
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=chunk-J3GE7DEU.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/promise/timeout.ts"],"sourcesContent":["import { delay } from './delay.ts';\nimport { TimeoutError } from '../error/TimeoutError.ts';\n\n/**\n * Returns a promise that rejects with a `TimeoutError` after a specified delay.\n *\n * @param {number} ms - The delay duration in milliseconds.\n * @returns {Promise<void>} A promise that rejects with a `TimeoutError` after the specified delay.\n * @throws {TimeoutError} Throws a `TimeoutError` after the specified delay.\n */\nexport async function timeout(ms: number): Promise<never> {\n await delay(ms);\n throw new TimeoutError();\n}\n"],"mappings":";;;;;;;;;;;AAUA,SAAsB,QAAQ,IAA4B;AAAA;AACxD,UAAM,MAAM,EAAE;AACd,UAAM,IAAI,aAAa;AAAA,EACzB;AAAA;","names":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// src/error/TimeoutError.ts
|
|
2
|
+
var TimeoutError = class extends Error {
|
|
3
|
+
constructor(message = "The operation was timed out") {
|
|
4
|
+
super(message);
|
|
5
|
+
this.name = "TimeoutError";
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export {
|
|
10
|
+
TimeoutError
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=chunk-KIOYQRMQ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/error/TimeoutError.ts"],"sourcesContent":["/**\n * An error class representing an timeout operation.\n * @augments Error\n */\nexport class TimeoutError extends Error {\n constructor(message = 'The operation was timed out') {\n super(message);\n this.name = 'TimeoutError';\n }\n}\n"],"mappings":";AAIO,IAAM,eAAN,cAA2B,MAAM;AAAA,EACtC,YAAY,UAAU,+BAA+B;AACnD,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;","names":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// src/array/dropRightWhile.ts
|
|
2
|
+
function dropRightWhile(arr, canContinueDropping) {
|
|
3
|
+
for (let i = arr.length - 1; i >= 0; i--) {
|
|
4
|
+
if (!canContinueDropping(arr[i])) {
|
|
5
|
+
return arr.slice(0, i + 1);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
return [];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
dropRightWhile
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=chunk-M7SBBYV2.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/array/dropRightWhile.ts"],"sourcesContent":["/**\n * Removes elements from the end of an array until the predicate returns false.\n *\n * This function iterates over an array from the end and drops elements until the provided\n * predicate function returns false. It then returns a new array with the remaining elements.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array from which to drop elements.\n * @param {(item: T) => boolean} canContinueDropping - A predicate function that determines\n * whether to continue dropping elements. The function is called with each element from the end,\n * and dropping continues as long as it returns true.\n * @returns {T[]} A new array with the elements remaining after the predicate returns false.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * const result = dropRightWhile(array, x => x > 3);\n * // result will be [1, 2, 3] since elements greater than 3 are dropped from the end.\n */\nexport function dropRightWhile<T>(arr: readonly T[], canContinueDropping: (item: T) => boolean): T[] {\n for (let i = arr.length - 1; i >= 0; i--) {\n if (!canContinueDropping(arr[i])) {\n return arr.slice(0, i + 1);\n }\n }\n\n return [];\n}\n"],"mappings":";AAkBO,SAAS,eAAkB,KAAmB,qBAAgD;AACnG,WAAS,IAAI,IAAI,SAAS,GAAG,KAAK,GAAG,KAAK;AACxC,QAAI,CAAC,oBAAoB,IAAI,CAAC,CAAC,GAAG;AAChC,aAAO,IAAI,MAAM,GAAG,IAAI,CAAC;AAAA,IAC3B;AAAA,EACF;AAEA,SAAO,CAAC;AACV;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
mean
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-5ASRKEB4.mjs";
|
|
4
4
|
|
|
5
5
|
// src/math/meanBy.ts
|
|
6
6
|
function meanBy(items, getValue) {
|
|
@@ -11,4 +11,4 @@ function meanBy(items, getValue) {
|
|
|
11
11
|
export {
|
|
12
12
|
meanBy
|
|
13
13
|
};
|
|
14
|
-
//# sourceMappingURL=chunk-
|
|
14
|
+
//# sourceMappingURL=chunk-MY4G7R3I.mjs.map
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
// src/object/invert.ts
|
|
2
2
|
function invert(obj) {
|
|
3
3
|
const result = {};
|
|
4
|
-
|
|
4
|
+
const keys = Object.keys(obj);
|
|
5
|
+
for (let i = 0; i < keys.length; i++) {
|
|
6
|
+
const key = keys[i];
|
|
5
7
|
const value = obj[key];
|
|
6
8
|
result[value] = key;
|
|
7
9
|
}
|
|
@@ -11,4 +13,4 @@ function invert(obj) {
|
|
|
11
13
|
export {
|
|
12
14
|
invert
|
|
13
15
|
};
|
|
14
|
-
//# sourceMappingURL=chunk-
|
|
16
|
+
//# sourceMappingURL=chunk-OLX53VEF.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/object/invert.ts"],"sourcesContent":["/**\n * Inverts the keys and values of an object. The keys of the input object become the values of the output object and vice versa.\n *\n * This function takes an object and creates a new object by inverting its keys and values. If the input object has duplicate values,\n * the key of the last occurrence will be used as the value for the new key in the output object. It effectively creates a reverse mapping\n * of the input object's key-value pairs.\n *\n * @template K - Type of the keys in the input object (string, number, symbol)\n * @template V - Type of the values in the input object (string, number, symbol)\n * @param {Record<K, V>} obj - The input object whose keys and values are to be inverted\n * @returns {{ [key in V]: K }} - A new object with keys and values inverted\n *\n * @example\n * invert({ a: 1, b: 2, c: 3 }); // { 1: 'a', 2: 'b', 3: 'c' }\n * invert({ 1: 'a', 2: 'b', 3: 'c' }); // { a: '1', b: '2', c: '3' }\n * invert({ a: 1, 2: 'b', c: 3, 4: 'd' }); // { 1: 'a', b: '2', 3: 'c', d: '4' }\n * invert({ a: Symbol('sym1'), b: Symbol('sym2') }); // { [Symbol('sym1')]: 'a', [Symbol('sym2')]: 'b' }\n */\nexport function invert<K extends PropertyKey, V extends PropertyKey>(obj: Record<K, V>): { [key in V]: K } {\n const result = {} as { [key in V]: K };\n\n for (
|
|
1
|
+
{"version":3,"sources":["../src/object/invert.ts"],"sourcesContent":["/**\n * Inverts the keys and values of an object. The keys of the input object become the values of the output object and vice versa.\n *\n * This function takes an object and creates a new object by inverting its keys and values. If the input object has duplicate values,\n * the key of the last occurrence will be used as the value for the new key in the output object. It effectively creates a reverse mapping\n * of the input object's key-value pairs.\n *\n * @template K - Type of the keys in the input object (string, number, symbol)\n * @template V - Type of the values in the input object (string, number, symbol)\n * @param {Record<K, V>} obj - The input object whose keys and values are to be inverted\n * @returns {{ [key in V]: K }} - A new object with keys and values inverted\n *\n * @example\n * invert({ a: 1, b: 2, c: 3 }); // { 1: 'a', 2: 'b', 3: 'c' }\n * invert({ 1: 'a', 2: 'b', 3: 'c' }); // { a: '1', b: '2', c: '3' }\n * invert({ a: 1, 2: 'b', c: 3, 4: 'd' }); // { 1: 'a', b: '2', 3: 'c', d: '4' }\n * invert({ a: Symbol('sym1'), b: Symbol('sym2') }); // { [Symbol('sym1')]: 'a', [Symbol('sym2')]: 'b' }\n */\nexport function invert<K extends PropertyKey, V extends PropertyKey>(obj: Record<K, V>): { [key in V]: K } {\n const result = {} as { [key in V]: K };\n\n const keys = Object.keys(obj) as K[];\n \n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n const value = obj[key];\n result[value] = key;\n }\n\n return result;\n}\n"],"mappings":";AAkBO,SAAS,OAAqD,KAAsC;AACzG,QAAM,SAAS,CAAC;AAEhB,QAAM,OAAO,OAAO,KAAK,GAAG;AAE5B,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,UAAM,MAAM,KAAK,CAAC;AAClB,UAAM,QAAQ,IAAI,GAAG;AACrB,WAAO,KAAK,IAAI;AAAA,EAClB;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// src/array/dropRight.ts
|
|
2
|
+
function dropRight(arr, itemsCount) {
|
|
3
|
+
itemsCount = Math.min(-itemsCount, 0);
|
|
4
|
+
if (itemsCount === 0) {
|
|
5
|
+
return arr.slice();
|
|
6
|
+
}
|
|
7
|
+
return arr.slice(0, itemsCount);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
dropRight
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=chunk-OXZCMC5I.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/array/dropRight.ts"],"sourcesContent":["/**\n * Removes a specified number of elements from the end of an array and returns the rest.\n *\n * This function takes an array and a number, and returns a new array with the specified number\n * of elements removed from the end.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array from which to drop elements.\n * @param {number} itemsCount - The number of elements to drop from the end of the array.\n * @returns {T[]} A new array with the specified number of elements removed from the end.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * const result = dropRight(array, 2);\n * // result will be [1, 2, 3] since the last two elements are dropped.\n */\nexport function dropRight<T>(arr: readonly T[], itemsCount: number): T[] {\n return arr.slice(0,
|
|
1
|
+
{"version":3,"sources":["../src/array/dropRight.ts"],"sourcesContent":["/**\n * Removes a specified number of elements from the end of an array and returns the rest.\n *\n * This function takes an array and a number, and returns a new array with the specified number\n * of elements removed from the end.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array from which to drop elements.\n * @param {number} itemsCount - The number of elements to drop from the end of the array.\n * @returns {T[]} A new array with the specified number of elements removed from the end.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * const result = dropRight(array, 2);\n * // result will be [1, 2, 3] since the last two elements are dropped.\n */\nexport function dropRight<T>(arr: readonly T[], itemsCount: number): T[] {\n itemsCount = Math.min(-itemsCount, 0);\n\n if (itemsCount === 0) {\n return arr.slice();\n }\n\n return arr.slice(0, itemsCount);\n}\n"],"mappings":";AAgBO,SAAS,UAAa,KAAmB,YAAyB;AACvE,eAAa,KAAK,IAAI,CAAC,YAAY,CAAC;AAEpC,MAAI,eAAe,GAAG;AACpB,WAAO,IAAI,MAAM;AAAA,EACnB;AAEA,SAAO,IAAI,MAAM,GAAG,UAAU;AAChC;","names":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getWords
|
|
3
|
+
} from "./chunk-WVQ7YVRK.mjs";
|
|
4
|
+
|
|
5
|
+
// src/string/startCase.ts
|
|
6
|
+
function startCase(str) {
|
|
7
|
+
const words = getWords(str.trim());
|
|
8
|
+
let result = "";
|
|
9
|
+
for (const word of words) {
|
|
10
|
+
if (result) {
|
|
11
|
+
result += " ";
|
|
12
|
+
}
|
|
13
|
+
if (word === word.toUpperCase()) {
|
|
14
|
+
result += word;
|
|
15
|
+
} else {
|
|
16
|
+
result += word[0].toUpperCase() + word.slice(1).toLowerCase();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export {
|
|
23
|
+
startCase
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=chunk-QXTNZR7B.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/string/startCase.ts"],"sourcesContent":["import { getWords } from './_internal/getWords.ts';\n\n/**\n * Converts the first character of each word in a string to uppercase and the remaining characters to lowercase.\n *\n * Start case is the naming convention in which each word is written with an initial capital letter.\n * @param {string} str - The string to convert.\n * @returns {string} The converted string.\n *\n * @example\n * const result1 = startCase('hello world'); // result will be 'Hello World'\n * const result2 = startCase('HELLO WORLD'); // result will be 'Hello World'\n * const result3 = startCase('hello-world'); // result will be 'Hello World'\n * const result4 = startCase('hello_world'); // result will be 'Hello World'\n */\nexport function startCase(str: string): string {\n const words = getWords(str.trim());\n let result = '';\n for (const word of words) {\n if (result) {\n result += ' ';\n }\n if (word === word.toUpperCase()) {\n result += word;\n } else {\n result += word[0].toUpperCase() + word.slice(1).toLowerCase();\n }\n }\n return result;\n}\n"],"mappings":";;;;;AAeO,SAAS,UAAU,KAAqB;AAC7C,QAAM,QAAQ,SAAS,IAAI,KAAK,CAAC;AACjC,MAAI,SAAS;AACb,aAAW,QAAQ,OAAO;AACxB,QAAI,QAAQ;AACV,gBAAU;AAAA,IACZ;AACA,QAAI,SAAS,KAAK,YAAY,GAAG;AAC/B,gBAAU;AAAA,IACZ,OAAO;AACL,gBAAU,KAAK,CAAC,EAAE,YAAY,IAAI,KAAK,MAAM,CAAC,EAAE,YAAY;AAAA,IAC9D;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__spreadValues
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-424M7IR7.mjs";
|
|
4
4
|
|
|
5
5
|
// src/object/omit.ts
|
|
6
6
|
function omit(obj, keys) {
|
|
@@ -14,4 +14,4 @@ function omit(obj, keys) {
|
|
|
14
14
|
export {
|
|
15
15
|
omit
|
|
16
16
|
};
|
|
17
|
-
//# sourceMappingURL=chunk-
|
|
17
|
+
//# sourceMappingURL=chunk-U7V3G7CR.mjs.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
flatten
|
|
3
|
+
} from "./chunk-33MSBDC6.mjs";
|
|
4
|
+
|
|
5
|
+
// src/array/flatMap.ts
|
|
6
|
+
function flatMap(arr, iteratee, depth = 1) {
|
|
7
|
+
return flatten(arr.map((item) => iteratee(item)), depth);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
flatMap
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=chunk-UY76KTPE.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/array/flatMap.ts"],"sourcesContent":["import { flatten } from './flatten.ts';\n\n/**\n * Maps each element in the array using the iteratee function and flattens the result up to the specified depth.\n *\n * @template T - The type of elements within the array.\n * @template U - The type of elements within the returned array from the iteratee function.\n * @template D - The depth to which the array should be flattened.\n * @param {T[]} arr - The array to flatten.\n * @param {(item: T) => U} iteratee - The function that produces the new array elements.\n * @param {D} depth - The depth level specifying how deep a nested array structure should be flattened. Defaults to 1.\n * @returns {Array<FlatArray<U[], D>>} The new array with the mapped and flattened elements.\n *\n * @example\n * const arr = [1, 2, 3];\n *\n * flatMap(arr, (item: number) => [item, item]);\n * // [1, 1, 2, 2, 3, 3]\n *\n * flatMap(arr, (item: number) => [[item, item]], 2);\n * // [1, 1, 2, 2, 3, 3]\n */\nexport function flatMap<T, U, D extends number>(\n arr: readonly T[],\n iteratee: (item: T) => U,\n depth = 1 as D\n): Array<FlatArray<U[], D>> {\n return flatten(arr.map(item => iteratee(item)), depth);\n}\n"],"mappings":";;;;;AAsBO,SAAS,QACd,KACA,UACA,QAAQ,GACkB;AAC1B,SAAO,QAAQ,IAAI,IAAI,UAAQ,SAAS,IAAI,CAAC,GAAG,KAAK;AACvD;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-XT74R35S.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
timeout
|
|
3
|
+
} from "./chunk-J3GE7DEU.mjs";
|
|
4
|
+
import {
|
|
5
|
+
__async
|
|
6
|
+
} from "./chunk-424M7IR7.mjs";
|
|
7
|
+
|
|
8
|
+
// src/promise/withTimeout.ts
|
|
9
|
+
function withTimeout(run, ms) {
|
|
10
|
+
return __async(this, null, function* () {
|
|
11
|
+
return Promise.race([run(), timeout(ms)]);
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export {
|
|
16
|
+
withTimeout
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=chunk-XWPCDIFC.mjs.map
|
|
@@ -0,0 +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":";;;;;;;;AAqBA,SAAsB,YAAe,KAAuB,IAAwB;AAAA;AAClF,WAAO,QAAQ,KAAK,CAAC,IAAI,GAAG,QAAQ,EAAE,CAAM,CAAC;AAAA,EAC/C;AAAA;","names":[]}
|