es-toolkit 1.10.0 → 1.10.1-dev.213
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 +6 -1
- package/LICENSE +7 -1
- 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.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/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.mjs +17 -17
- 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/chunk-2MM5EJJX.mjs +21 -0
- package/dist/chunk-5L4VWRFX.mjs +14 -0
- package/dist/chunk-5L4VWRFX.mjs.map +1 -0
- package/dist/chunk-FUS75PJ7.mjs +1 -0
- package/dist/chunk-NKLIE2OI.mjs +1 -0
- package/dist/chunk-NKLIE2OI.mjs.map +1 -0
- package/dist/{chunk-4E4D3BMI.mjs → chunk-QZITBKWX.mjs} +2 -2
- package/dist/chunk-Y5V7UAZZ.mjs +21 -0
- package/dist/chunk-Y5V7UAZZ.mjs.map +1 -0
- package/dist/compat/index.d.mts +109 -0
- package/dist/compat/index.d.ts +109 -0
- package/dist/compat/index.js +1077 -0
- package/dist/compat/index.js.map +1 -0
- package/dist/compat/index.mjs +355 -0
- package/dist/compat/index.mjs.map +1 -0
- package/dist/error/AbortError.mjs +1 -1
- package/dist/error/index.mjs +1 -1
- package/dist/function/debounce.mjs +1 -1
- package/dist/function/index.mjs +4 -4
- 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 +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +14 -5515
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +89 -84
- package/dist/math/clamp.mjs +1 -1
- package/dist/math/inRange.mjs +1 -1
- package/dist/math/index.d.mts +1 -0
- package/dist/math/index.d.ts +1 -0
- package/dist/math/index.js +10 -2
- package/dist/math/index.js.map +1 -1
- package/dist/math/index.mjs +19 -15
- 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.d.mts +18 -0
- package/dist/math/sumBy.d.ts +18 -0
- package/dist/math/sumBy.js +45 -0
- package/dist/math/sumBy.js.map +1 -0
- package/dist/math/sumBy.mjs +9 -0
- package/dist/math/sumBy.mjs.map +1 -0
- package/dist/object/clone.mjs +1 -1
- package/dist/object/index.mjs +5 -5
- package/dist/object/invert.mjs +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.mjs +7 -7
- 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.mjs +1 -1
- package/dist/string/camelCase.js +6 -5508
- package/dist/string/camelCase.js.map +1 -1
- package/dist/string/camelCase.mjs +3 -2
- package/dist/string/capitalize.mjs +1 -1
- package/dist/string/index.js +6 -5515
- package/dist/string/index.js.map +1 -1
- package/dist/string/index.mjs +3 -3
- package/dist/string/kebabCase.mjs +1 -1
- package/dist/string/lowerCase.mjs +1 -1
- package/dist/string/snakeCase.mjs +1 -1
- package/package.json +3 -5
- package/dist/chunk-2HIMLZE3.mjs +0 -46
- package/dist/chunk-TLVQSNOE.mjs +0 -1
- package/dist/chunk-XGCYC4YA.mjs +0 -5516
- package/dist/chunk-XGCYC4YA.mjs.map +0 -1
- /package/dist/{chunk-2HIMLZE3.mjs.map → chunk-2MM5EJJX.mjs.map} +0 -0
- /package/dist/{chunk-TLVQSNOE.mjs.map → chunk-FUS75PJ7.mjs.map} +0 -0
- /package/dist/{chunk-4E4D3BMI.mjs.map → chunk-QZITBKWX.mjs.map} +0 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
sum
|
|
3
|
+
} from "./chunk-2SLTL4KL.mjs";
|
|
4
|
+
|
|
5
|
+
// src/math/sumBy.ts
|
|
6
|
+
function sumBy(items, getValue) {
|
|
7
|
+
const nums = items.map((x) => getValue(x));
|
|
8
|
+
return sum(nums);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
sumBy
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=chunk-5L4VWRFX.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/math/sumBy.ts"],"sourcesContent":["import { sum } from './sum.ts';\n\n/**\n * Calculates the sum of an array of numbers when applying\n * the `getValue` function to each element.\n *\n * If the array is empty, this function returns `0`.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} items An array to calculate the average.\n * @param {(element: T) => number} getValue A function that selects a numeric value from each element.\n * @returns {number} The average of all the numbers as determined by the `getValue` function.\n *\n * @example\n * sumBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: 6\n * sumBy([], x => x.a); // Returns: 0\n */\nexport function sumBy<T>(items: readonly T[], getValue: (element: T) => number): number {\n const nums = items.map(x => getValue(x));\n\n return sum(nums);\n}\n"],"mappings":";;;;;AAiBO,SAAS,MAAS,OAAqB,UAA0C;AACtF,QAAM,OAAO,MAAM,IAAI,OAAK,SAAS,CAAC,CAAC;AAEvC,SAAO,IAAI,IAAI;AACjB;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-FUS75PJ7.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-NKLIE2OI.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__spreadValues
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-2MM5EJJX.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-QZITBKWX.mjs.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {
|
|
2
|
+
capitalize
|
|
3
|
+
} from "./chunk-U56ZOM7L.mjs";
|
|
4
|
+
import {
|
|
5
|
+
getWords
|
|
6
|
+
} from "./chunk-WVQ7YVRK.mjs";
|
|
7
|
+
|
|
8
|
+
// src/string/camelCase.ts
|
|
9
|
+
function camelCase(str) {
|
|
10
|
+
const words = getWords(str);
|
|
11
|
+
if (words.length === 0) {
|
|
12
|
+
return "";
|
|
13
|
+
}
|
|
14
|
+
const [first, ...rest] = words;
|
|
15
|
+
return `${first.toLowerCase()}${rest.map((word) => capitalize(word)).join("")}`;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export {
|
|
19
|
+
camelCase
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=chunk-Y5V7UAZZ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/string/camelCase.ts"],"sourcesContent":["import { capitalize } from \"./capitalize.ts\";\nimport { getWords } from \"./_internal/getWords.ts\";\n\n/**\n * Converts a string to camel case.\n *\n * camel case is the naming convention in which each word is written in lowercase and separated by an underscore (_) character.\n *\n * @param {string} str - The string that is to be changed to camel case.\n * @returns {string} - The converted string to camel case.\n *\n * @example\n * const convertedStr1 = camelCase('camelCase') // returns 'camelCase'\n * const convertedStr2 = camelCase('some whitespace') // returns 'someWhitespace'\n * const convertedStr3 = camelCase('hyphen-text') // returns 'hyphenText'\n * const convertedStr4 = camelCase('HTTPRequest') // returns 'httpRequest'\n */\n\nexport function camelCase(str: string): string {\n const words = getWords(str);\n\n if (words.length === 0) {\n return \"\";\n }\n\n const [first, ...rest] = words;\n\n return `${first.toLowerCase()}${rest.map((word) => capitalize(word)).join(\"\")\n }`;\n}\n"],"mappings":";;;;;;;;AAkBO,SAAS,UAAU,KAAqB;AAC7C,QAAM,QAAQ,SAAS,GAAG;AAE1B,MAAI,MAAM,WAAW,GAAG;AACtB,WAAO;AAAA,EACT;AAEA,QAAM,CAAC,OAAO,GAAG,IAAI,IAAI;AAEzB,SAAO,GAAG,MAAM,YAAY,CAAC,GAAG,KAAK,IAAI,CAAC,SAAS,WAAW,IAAI,CAAC,EAAE,KAAK,EAAE,CAC1E;AACJ;","names":[]}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
export { compact } from '../array/compact.mjs';
|
|
2
|
+
export { countBy } from '../array/countBy.mjs';
|
|
3
|
+
export { difference } from '../array/difference.mjs';
|
|
4
|
+
export { differenceBy } from '../array/differenceBy.mjs';
|
|
5
|
+
export { differenceWith } from '../array/differenceWith.mjs';
|
|
6
|
+
export { drop } from '../array/drop.mjs';
|
|
7
|
+
export { dropRight } from '../array/dropRight.mjs';
|
|
8
|
+
export { dropRightWhile } from '../array/dropRightWhile.mjs';
|
|
9
|
+
export { dropWhile } from '../array/dropWhile.mjs';
|
|
10
|
+
export { fill } from '../array/fill.mjs';
|
|
11
|
+
export { flatten } from '../array/flatten.mjs';
|
|
12
|
+
export { flattenDeep } from '../array/flattenDeep.mjs';
|
|
13
|
+
export { forEachRight } from '../array/forEachRight.mjs';
|
|
14
|
+
export { groupBy } from '../array/groupBy.mjs';
|
|
15
|
+
export { intersection } from '../array/intersection.mjs';
|
|
16
|
+
export { intersectionBy } from '../array/intersectionBy.mjs';
|
|
17
|
+
export { intersectionWith } from '../array/intersectionWith.mjs';
|
|
18
|
+
export { keyBy } from '../array/keyBy.mjs';
|
|
19
|
+
export { maxBy } from '../array/maxBy.mjs';
|
|
20
|
+
export { minBy } from '../array/minBy.mjs';
|
|
21
|
+
export { orderBy } from '../array/orderBy.mjs';
|
|
22
|
+
export { partition } from '../array/partition.mjs';
|
|
23
|
+
export { sample } from '../array/sample.mjs';
|
|
24
|
+
export { sampleSize } from '../array/sampleSize.mjs';
|
|
25
|
+
export { shuffle } from '../array/shuffle.mjs';
|
|
26
|
+
export { take } from '../array/take.mjs';
|
|
27
|
+
export { takeRight } from '../array/takeRight.mjs';
|
|
28
|
+
export { takeRightWhile } from '../array/takeRightWhile.mjs';
|
|
29
|
+
export { takeWhile } from '../array/takeWhile.mjs';
|
|
30
|
+
export { union } from '../array/union.mjs';
|
|
31
|
+
export { unionBy } from '../array/unionBy.mjs';
|
|
32
|
+
export { unionWith } from '../array/unionWith.mjs';
|
|
33
|
+
export { uniq } from '../array/uniq.mjs';
|
|
34
|
+
export { uniqBy } from '../array/uniqBy.mjs';
|
|
35
|
+
export { uniqWith } from '../array/uniqWith.mjs';
|
|
36
|
+
export { unzip } from '../array/unzip.mjs';
|
|
37
|
+
export { unzipWith } from '../array/unzipWith.mjs';
|
|
38
|
+
export { xor } from '../array/xor.mjs';
|
|
39
|
+
export { xorBy } from '../array/xorBy.mjs';
|
|
40
|
+
export { xorWith } from '../array/xorWith.mjs';
|
|
41
|
+
export { zip } from '../array/zip.mjs';
|
|
42
|
+
export { zipObject } from '../array/zipObject.mjs';
|
|
43
|
+
export { zipWith } from '../array/zipWith.mjs';
|
|
44
|
+
export { without } from '../array/without.mjs';
|
|
45
|
+
export { head } from '../array/head.mjs';
|
|
46
|
+
export { tail } from '../array/tail.mjs';
|
|
47
|
+
export { toFilled } from '../array/toFilled.mjs';
|
|
48
|
+
export { last } from '../array/last.mjs';
|
|
49
|
+
export { initial } from '../array/initial.mjs';
|
|
50
|
+
export { AbortError } from '../error/AbortError.mjs';
|
|
51
|
+
export { debounce } from '../function/debounce.mjs';
|
|
52
|
+
export { noop } from '../function/noop.mjs';
|
|
53
|
+
export { once } from '../function/once.mjs';
|
|
54
|
+
export { throttle } from '../function/throttle.mjs';
|
|
55
|
+
export { negate } from '../function/negate.mjs';
|
|
56
|
+
export { clamp } from '../math/clamp.mjs';
|
|
57
|
+
export { inRange } from '../math/inRange.mjs';
|
|
58
|
+
export { mean } from '../math/mean.mjs';
|
|
59
|
+
export { meanBy } from '../math/meanBy.mjs';
|
|
60
|
+
export { random } from '../math/random.mjs';
|
|
61
|
+
export { randomInt } from '../math/randomInt.mjs';
|
|
62
|
+
export { round } from '../math/round.mjs';
|
|
63
|
+
export { sum } from '../math/sum.mjs';
|
|
64
|
+
export { sumBy } from '../math/sumBy.mjs';
|
|
65
|
+
export { range } from '../math/range.mjs';
|
|
66
|
+
export { omit } from '../object/omit.mjs';
|
|
67
|
+
export { omitBy } from '../object/omitBy.mjs';
|
|
68
|
+
export { pick } from '../object/pick.mjs';
|
|
69
|
+
export { pickBy } from '../object/pickBy.mjs';
|
|
70
|
+
export { invert } from '../object/invert.mjs';
|
|
71
|
+
export { clone } from '../object/clone.mjs';
|
|
72
|
+
export { isEqual } from '../predicate/isEqual.mjs';
|
|
73
|
+
export { isNil } from '../predicate/isNil.mjs';
|
|
74
|
+
export { isNotNil } from '../predicate/isNotNil.mjs';
|
|
75
|
+
export { isNull } from '../predicate/isNull.mjs';
|
|
76
|
+
export { isUndefined } from '../predicate/isUndefined.mjs';
|
|
77
|
+
export { delay } from '../promise/delay.mjs';
|
|
78
|
+
export { camelCase } from '../string/camelCase.mjs';
|
|
79
|
+
export { snakeCase } from '../string/snakeCase.mjs';
|
|
80
|
+
export { kebabCase } from '../string/kebabCase.mjs';
|
|
81
|
+
export { lowerCase } from '../string/lowerCase.mjs';
|
|
82
|
+
export { capitalize } from '../string/capitalize.mjs';
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Splits an array into smaller arrays of a specified length.
|
|
86
|
+
*
|
|
87
|
+
* This function takes an input array and divides it into multiple smaller arrays,
|
|
88
|
+
* each of a specified length. If the input array cannot be evenly divided,
|
|
89
|
+
* the final sub-array will contain the remaining elements.
|
|
90
|
+
*
|
|
91
|
+
* @template T The type of elements in the array.
|
|
92
|
+
* @param {T[]} arr - The array to be chunked into smaller arrays.
|
|
93
|
+
* @param {number} size - The size of each smaller array. Must be a positive integer.
|
|
94
|
+
* @returns {T[][]} A two-dimensional array where each sub-array has a maximum length of `size`.
|
|
95
|
+
* @throws {Error} Throws an error if `size` is not a positive integer.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* // Splits an array of numbers into sub-arrays of length 2
|
|
99
|
+
* chunk([1, 2, 3, 4, 5], 2);
|
|
100
|
+
* // Returns: [[1, 2], [3, 4], [5]]
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* // Splits an array of strings into sub-arrays of length 3
|
|
104
|
+
* chunk(['a', 'b', 'c', 'd', 'e', 'f', 'g'], 3);
|
|
105
|
+
* // Returns: [['a', 'b', 'c'], ['d', 'e', 'f'], ['g']]
|
|
106
|
+
*/
|
|
107
|
+
declare function chunk<T>(arr: readonly T[], size?: number): T[][];
|
|
108
|
+
|
|
109
|
+
export { chunk };
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
export { compact } from '../array/compact.js';
|
|
2
|
+
export { countBy } from '../array/countBy.js';
|
|
3
|
+
export { difference } from '../array/difference.js';
|
|
4
|
+
export { differenceBy } from '../array/differenceBy.js';
|
|
5
|
+
export { differenceWith } from '../array/differenceWith.js';
|
|
6
|
+
export { drop } from '../array/drop.js';
|
|
7
|
+
export { dropRight } from '../array/dropRight.js';
|
|
8
|
+
export { dropRightWhile } from '../array/dropRightWhile.js';
|
|
9
|
+
export { dropWhile } from '../array/dropWhile.js';
|
|
10
|
+
export { fill } from '../array/fill.js';
|
|
11
|
+
export { flatten } from '../array/flatten.js';
|
|
12
|
+
export { flattenDeep } from '../array/flattenDeep.js';
|
|
13
|
+
export { forEachRight } from '../array/forEachRight.js';
|
|
14
|
+
export { groupBy } from '../array/groupBy.js';
|
|
15
|
+
export { intersection } from '../array/intersection.js';
|
|
16
|
+
export { intersectionBy } from '../array/intersectionBy.js';
|
|
17
|
+
export { intersectionWith } from '../array/intersectionWith.js';
|
|
18
|
+
export { keyBy } from '../array/keyBy.js';
|
|
19
|
+
export { maxBy } from '../array/maxBy.js';
|
|
20
|
+
export { minBy } from '../array/minBy.js';
|
|
21
|
+
export { orderBy } from '../array/orderBy.js';
|
|
22
|
+
export { partition } from '../array/partition.js';
|
|
23
|
+
export { sample } from '../array/sample.js';
|
|
24
|
+
export { sampleSize } from '../array/sampleSize.js';
|
|
25
|
+
export { shuffle } from '../array/shuffle.js';
|
|
26
|
+
export { take } from '../array/take.js';
|
|
27
|
+
export { takeRight } from '../array/takeRight.js';
|
|
28
|
+
export { takeRightWhile } from '../array/takeRightWhile.js';
|
|
29
|
+
export { takeWhile } from '../array/takeWhile.js';
|
|
30
|
+
export { union } from '../array/union.js';
|
|
31
|
+
export { unionBy } from '../array/unionBy.js';
|
|
32
|
+
export { unionWith } from '../array/unionWith.js';
|
|
33
|
+
export { uniq } from '../array/uniq.js';
|
|
34
|
+
export { uniqBy } from '../array/uniqBy.js';
|
|
35
|
+
export { uniqWith } from '../array/uniqWith.js';
|
|
36
|
+
export { unzip } from '../array/unzip.js';
|
|
37
|
+
export { unzipWith } from '../array/unzipWith.js';
|
|
38
|
+
export { xor } from '../array/xor.js';
|
|
39
|
+
export { xorBy } from '../array/xorBy.js';
|
|
40
|
+
export { xorWith } from '../array/xorWith.js';
|
|
41
|
+
export { zip } from '../array/zip.js';
|
|
42
|
+
export { zipObject } from '../array/zipObject.js';
|
|
43
|
+
export { zipWith } from '../array/zipWith.js';
|
|
44
|
+
export { without } from '../array/without.js';
|
|
45
|
+
export { head } from '../array/head.js';
|
|
46
|
+
export { tail } from '../array/tail.js';
|
|
47
|
+
export { toFilled } from '../array/toFilled.js';
|
|
48
|
+
export { last } from '../array/last.js';
|
|
49
|
+
export { initial } from '../array/initial.js';
|
|
50
|
+
export { AbortError } from '../error/AbortError.js';
|
|
51
|
+
export { debounce } from '../function/debounce.js';
|
|
52
|
+
export { noop } from '../function/noop.js';
|
|
53
|
+
export { once } from '../function/once.js';
|
|
54
|
+
export { throttle } from '../function/throttle.js';
|
|
55
|
+
export { negate } from '../function/negate.js';
|
|
56
|
+
export { clamp } from '../math/clamp.js';
|
|
57
|
+
export { inRange } from '../math/inRange.js';
|
|
58
|
+
export { mean } from '../math/mean.js';
|
|
59
|
+
export { meanBy } from '../math/meanBy.js';
|
|
60
|
+
export { random } from '../math/random.js';
|
|
61
|
+
export { randomInt } from '../math/randomInt.js';
|
|
62
|
+
export { round } from '../math/round.js';
|
|
63
|
+
export { sum } from '../math/sum.js';
|
|
64
|
+
export { sumBy } from '../math/sumBy.js';
|
|
65
|
+
export { range } from '../math/range.js';
|
|
66
|
+
export { omit } from '../object/omit.js';
|
|
67
|
+
export { omitBy } from '../object/omitBy.js';
|
|
68
|
+
export { pick } from '../object/pick.js';
|
|
69
|
+
export { pickBy } from '../object/pickBy.js';
|
|
70
|
+
export { invert } from '../object/invert.js';
|
|
71
|
+
export { clone } from '../object/clone.js';
|
|
72
|
+
export { isEqual } from '../predicate/isEqual.js';
|
|
73
|
+
export { isNil } from '../predicate/isNil.js';
|
|
74
|
+
export { isNotNil } from '../predicate/isNotNil.js';
|
|
75
|
+
export { isNull } from '../predicate/isNull.js';
|
|
76
|
+
export { isUndefined } from '../predicate/isUndefined.js';
|
|
77
|
+
export { delay } from '../promise/delay.js';
|
|
78
|
+
export { camelCase } from '../string/camelCase.js';
|
|
79
|
+
export { snakeCase } from '../string/snakeCase.js';
|
|
80
|
+
export { kebabCase } from '../string/kebabCase.js';
|
|
81
|
+
export { lowerCase } from '../string/lowerCase.js';
|
|
82
|
+
export { capitalize } from '../string/capitalize.js';
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Splits an array into smaller arrays of a specified length.
|
|
86
|
+
*
|
|
87
|
+
* This function takes an input array and divides it into multiple smaller arrays,
|
|
88
|
+
* each of a specified length. If the input array cannot be evenly divided,
|
|
89
|
+
* the final sub-array will contain the remaining elements.
|
|
90
|
+
*
|
|
91
|
+
* @template T The type of elements in the array.
|
|
92
|
+
* @param {T[]} arr - The array to be chunked into smaller arrays.
|
|
93
|
+
* @param {number} size - The size of each smaller array. Must be a positive integer.
|
|
94
|
+
* @returns {T[][]} A two-dimensional array where each sub-array has a maximum length of `size`.
|
|
95
|
+
* @throws {Error} Throws an error if `size` is not a positive integer.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* // Splits an array of numbers into sub-arrays of length 2
|
|
99
|
+
* chunk([1, 2, 3, 4, 5], 2);
|
|
100
|
+
* // Returns: [[1, 2], [3, 4], [5]]
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* // Splits an array of strings into sub-arrays of length 3
|
|
104
|
+
* chunk(['a', 'b', 'c', 'd', 'e', 'f', 'g'], 3);
|
|
105
|
+
* // Returns: [['a', 'b', 'c'], ['d', 'e', 'f'], ['g']]
|
|
106
|
+
*/
|
|
107
|
+
declare function chunk<T>(arr: readonly T[], size?: number): T[][];
|
|
108
|
+
|
|
109
|
+
export { chunk };
|