es-toolkit 1.5.0 → 1.6.0-dev.113
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 +11 -0
- package/dist/array/compact.d.mts +14 -0
- package/dist/array/compact.d.ts +14 -0
- package/dist/array/compact.js +39 -0
- package/dist/array/compact.js.map +1 -0
- package/dist/array/compact.mjs +8 -0
- package/dist/array/index.d.mts +3 -0
- package/dist/array/index.d.ts +3 -0
- package/dist/array/index.js +44 -8
- package/dist/array/index.js.map +1 -1
- package/dist/array/index.mjs +52 -40
- package/dist/array/keyBy.d.mts +28 -0
- package/dist/array/keyBy.d.ts +28 -0
- package/dist/array/keyBy.js +38 -0
- package/dist/array/keyBy.js.map +1 -0
- package/dist/array/keyBy.mjs +8 -0
- package/dist/array/maxBy.d.mts +8 -15
- package/dist/array/maxBy.d.ts +8 -15
- package/dist/array/maxBy.js +4 -4
- package/dist/array/maxBy.js.map +1 -1
- package/dist/array/maxBy.mjs +1 -1
- package/dist/array/minBy.d.mts +9 -8
- package/dist/array/minBy.d.ts +9 -8
- package/dist/array/minBy.js +4 -4
- package/dist/array/minBy.js.map +1 -1
- package/dist/array/minBy.mjs +1 -1
- package/dist/array/zipObject.d.mts +33 -0
- package/dist/array/zipObject.d.ts +33 -0
- package/dist/array/zipObject.js +37 -0
- package/dist/array/zipObject.js.map +1 -0
- package/dist/array/zipObject.mjs +8 -0
- package/dist/array/zipObject.mjs.map +1 -0
- package/dist/chunk-DA7GSKQ5.mjs +13 -0
- package/dist/chunk-DA7GSKQ5.mjs.map +1 -0
- package/dist/chunk-FXOABQRO.mjs +18 -0
- package/dist/chunk-FXOABQRO.mjs.map +1 -0
- package/dist/chunk-NKTBEEIT.mjs +15 -0
- package/dist/chunk-NKTBEEIT.mjs.map +1 -0
- package/dist/{chunk-7OU22ENP.mjs → chunk-NOFHNJ5C.mjs} +1 -1
- package/dist/{chunk-7OU22ENP.mjs.map → chunk-NOFHNJ5C.mjs.map} +1 -1
- package/dist/chunk-OIHARMNM.mjs +18 -0
- package/dist/chunk-OIHARMNM.mjs.map +1 -0
- package/dist/chunk-QVHWSUEH.mjs +1 -0
- package/dist/chunk-QVHWSUEH.mjs.map +1 -0
- package/dist/chunk-S3GNYAM2.mjs +13 -0
- package/dist/chunk-S3GNYAM2.mjs.map +1 -0
- package/dist/{chunk-LCP6FOCX.mjs → chunk-SYWMYQYJ.mjs} +5 -1
- package/dist/chunk-SYWMYQYJ.mjs.map +1 -0
- package/dist/chunk-V6MDTRGS.mjs +1 -0
- package/dist/chunk-V6MDTRGS.mjs.map +1 -0
- package/dist/{chunk-5UT77WON.mjs → chunk-WC5HFQXP.mjs} +2 -2
- package/dist/chunk-WC5HFQXP.mjs.map +1 -0
- package/dist/chunk-ZOTAORG3.mjs +14 -0
- package/dist/chunk-ZOTAORG3.mjs.map +1 -0
- package/dist/function/index.mjs +3 -3
- package/dist/index.d.mts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +64 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +85 -69
- package/dist/math/index.d.mts +1 -0
- package/dist/math/index.d.ts +1 -0
- package/dist/math/index.js +20 -9
- package/dist/math/index.js.map +1 -1
- package/dist/math/index.mjs +13 -9
- package/dist/math/mean.d.mts +16 -0
- package/dist/math/mean.d.ts +16 -0
- package/dist/math/mean.js +44 -0
- package/dist/math/mean.js.map +1 -0
- package/dist/math/mean.mjs +9 -0
- package/dist/math/mean.mjs.map +1 -0
- package/dist/math/random.d.mts +3 -0
- package/dist/math/random.d.ts +3 -0
- package/dist/math/random.js +4 -0
- package/dist/math/random.js.map +1 -1
- package/dist/math/random.mjs +1 -1
- package/dist/math/randomInt.d.mts +3 -0
- package/dist/math/randomInt.d.ts +3 -0
- package/dist/math/randomInt.js +4 -0
- package/dist/math/randomInt.js.map +1 -1
- package/dist/math/randomInt.mjs +2 -2
- package/dist/math/sum.d.mts +1 -1
- package/dist/math/sum.d.ts +1 -1
- package/dist/math/sum.js.map +1 -1
- package/dist/math/sum.mjs +1 -1
- package/dist/object/index.mjs +3 -3
- package/dist/predicate/index.mjs +6 -6
- package/package.json +1 -1
- package/dist/chunk-5UT77WON.mjs.map +0 -1
- package/dist/chunk-7LAMAYGN.mjs +0 -1
- package/dist/chunk-H23GUJVF.mjs +0 -18
- package/dist/chunk-H23GUJVF.mjs.map +0 -1
- package/dist/chunk-KZ5JY7J3.mjs +0 -18
- package/dist/chunk-KZ5JY7J3.mjs.map +0 -1
- package/dist/chunk-LCP6FOCX.mjs.map +0 -1
- package/dist/chunk-NP6PDX3E.mjs +0 -1
- /package/dist/{chunk-7LAMAYGN.mjs.map → array/compact.mjs.map} +0 -0
- /package/dist/{chunk-NP6PDX3E.mjs.map → array/keyBy.mjs.map} +0 -0
package/dist/math/sum.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/math/sum.ts"],"sourcesContent":["/**\n * Calculates the sum of an array of numbers.\n *\n * This function takes an array of numbers and returns the sum of all the elements in the array.\n *\n * @param {number[]} nums - An array of numbers to be summed.\n * @returns {number} The sum of all the numbers in the array.\n *\n * @example\n * const numbers = [1, 2, 3, 4, 5];\n * const result = sum(numbers);\n * // result will be 15\n */\nexport function sum(nums: number[]): number {\n let result = 0;\n\n for (const num of nums) {\n result += num;\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAaO,SAAS,IAAI,
|
|
1
|
+
{"version":3,"sources":["../../src/math/sum.ts"],"sourcesContent":["/**\n * Calculates the sum of an array of numbers.\n *\n * This function takes an array of numbers and returns the sum of all the elements in the array.\n *\n * @param {number[]} nums - An array of numbers to be summed.\n * @returns {number} The sum of all the numbers in the array.\n *\n * @example\n * const numbers = [1, 2, 3, 4, 5];\n * const result = sum(numbers);\n * // result will be 15\n */\nexport function sum(nums: readonly number[]): number {\n let result = 0;\n\n for (const num of nums) {\n result += num;\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAaO,SAAS,IAAI,MAAiC;AACnD,MAAI,SAAS;AAEb,aAAW,OAAO,MAAM;AACtB,cAAU;AAAA,EACZ;AAEA,SAAO;AACT;","names":[]}
|
package/dist/math/sum.mjs
CHANGED
package/dist/object/index.mjs
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import "../chunk-T5JCRGXA.mjs";
|
|
2
|
+
import {
|
|
3
|
+
pickBy
|
|
4
|
+
} from "../chunk-MQWVBKUT.mjs";
|
|
2
5
|
import {
|
|
3
6
|
omit
|
|
4
7
|
} from "../chunk-PLTO44KM.mjs";
|
|
@@ -8,9 +11,6 @@ import {
|
|
|
8
11
|
import {
|
|
9
12
|
pick
|
|
10
13
|
} from "../chunk-OFWKFUFZ.mjs";
|
|
11
|
-
import {
|
|
12
|
-
pickBy
|
|
13
|
-
} from "../chunk-MQWVBKUT.mjs";
|
|
14
14
|
import "../chunk-2MM5EJJX.mjs";
|
|
15
15
|
export {
|
|
16
16
|
omit,
|
package/dist/predicate/index.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import "../chunk-MAJSPFA6.mjs";
|
|
2
|
-
import {
|
|
3
|
-
isNull
|
|
4
|
-
} from "../chunk-AIRSKN47.mjs";
|
|
5
|
-
import {
|
|
6
|
-
isUndefined
|
|
7
|
-
} from "../chunk-VH2PV426.mjs";
|
|
8
2
|
import {
|
|
9
3
|
isNil
|
|
10
4
|
} from "../chunk-OHQAR5AU.mjs";
|
|
11
5
|
import {
|
|
12
6
|
isNotNil
|
|
13
7
|
} from "../chunk-ZQNAZPSK.mjs";
|
|
8
|
+
import {
|
|
9
|
+
isNull
|
|
10
|
+
} from "../chunk-AIRSKN47.mjs";
|
|
11
|
+
import {
|
|
12
|
+
isUndefined
|
|
13
|
+
} from "../chunk-VH2PV426.mjs";
|
|
14
14
|
import "../chunk-2MM5EJJX.mjs";
|
|
15
15
|
export {
|
|
16
16
|
isNil,
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/math/randomInt.ts"],"sourcesContent":["import { random } from './random';\n\n/**\n * Generates a random integer between minimum (inclusive) and maximum (exclusive).\n *\n * @param {number} minimum - The lower bound (inclusive).\n * @param {number} maximum - The upper bound (exclusive).\n * @returns {number} A random integer between minimum (inclusive) and maximum (exclusive).\n * @throws {Error} Throws an error if `maximum` is not greater than `minimum`.\n *\n * @example\n * const result = randomInt(0, 5); // result will be a random integer between 0 (inclusive) and 5 (exclusive)\n * const result2 = randomInt(5, 0); // This will throw an error\n */\nexport function randomInt(minimum: number, maximum: number): number {\n return Math.floor(random(minimum, maximum));\n}\n"],"mappings":";;;;;AAcO,SAAS,UAAU,SAAiB,SAAyB;AAClE,SAAO,KAAK,MAAM,OAAO,SAAS,OAAO,CAAC;AAC5C;","names":[]}
|
package/dist/chunk-7LAMAYGN.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=chunk-7LAMAYGN.mjs.map
|
package/dist/chunk-H23GUJVF.mjs
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// src/array/minBy.ts
|
|
2
|
-
function minBy(elements, selector) {
|
|
3
|
-
let minElement = elements[0];
|
|
4
|
-
let min = Infinity;
|
|
5
|
-
for (const element of elements) {
|
|
6
|
-
const value = selector(element);
|
|
7
|
-
if (value < min) {
|
|
8
|
-
min = value;
|
|
9
|
-
minElement = element;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
return minElement;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export {
|
|
16
|
-
minBy
|
|
17
|
-
};
|
|
18
|
-
//# sourceMappingURL=chunk-H23GUJVF.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/array/minBy.ts"],"sourcesContent":["/**\n * Returns the minimum value in an array of numbers.\n *\n * This function takes an array of elements and a selector function, and returns the element with the minimum value according to the selector.\n *\n * If the array is empty, the function returns `undefined`.\n *\n * @param elements An array of elements.\n * @param selector A function that selects a number from an element.\n */\nexport function minBy<T>(elements: T[], selector: (element: T) => number): T {\n let minElement = elements[0];\n let min = Infinity;\n\n for (const element of elements) {\n const value = selector(element);\n if (value < min) {\n min = value;\n minElement = element;\n }\n }\n\n return minElement;\n}\n"],"mappings":";AAUO,SAAS,MAAS,UAAe,UAAqC;AAC3E,MAAI,aAAa,SAAS,CAAC;AAC3B,MAAI,MAAM;AAEV,aAAW,WAAW,UAAU;AAC9B,UAAM,QAAQ,SAAS,OAAO;AAC9B,QAAI,QAAQ,KAAK;AACf,YAAM;AACN,mBAAa;AAAA,IACf;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
package/dist/chunk-KZ5JY7J3.mjs
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// src/array/maxBy.ts
|
|
2
|
-
function maxBy(elements, selector) {
|
|
3
|
-
let maxElement = elements[0];
|
|
4
|
-
let max = -Infinity;
|
|
5
|
-
for (const element of elements) {
|
|
6
|
-
const value = selector(element);
|
|
7
|
-
if (value > max) {
|
|
8
|
-
max = value;
|
|
9
|
-
maxElement = element;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
return maxElement;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export {
|
|
16
|
-
maxBy
|
|
17
|
-
};
|
|
18
|
-
//# sourceMappingURL=chunk-KZ5JY7J3.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/array/maxBy.ts"],"sourcesContent":["/**\n * Returns the element of the specified array that has the maximum value, according to the specified selector.\n *\n * This function takes an array of elements and a selector function, and returns the element with the maximum value according to the selector.\n *\n * @param {T[]} elements - An array of elements to be compared.\n * @param {(element: T) => number} selector - A function that takes an element and returns a number.\n * @returns {T} The element with the maximum value according to the selector.\n *\n * @example\n * const people = [\n * { name: 'Mark', age: 25 },\n * { name: 'Nunu', age: 30 },\n * { name: 'Overmars', age: 20 }\n * ];\n * const result = maxBy(people, person => person.age);\n * // result will be { name: 'Nunu', age: 30 }\n */\nexport function maxBy<T>(elements: T[], selector: (element: T) => number): T {\n let maxElement = elements[0];\n let max = -Infinity;\n\n for (const element of elements) {\n const value = selector(element);\n if (value > max) {\n max = value;\n maxElement = element;\n }\n }\n\n return maxElement;\n}\n"],"mappings":";AAkBO,SAAS,MAAS,UAAe,UAAqC;AAC3E,MAAI,aAAa,SAAS,CAAC;AAC3B,MAAI,MAAM;AAEV,aAAW,WAAW,UAAU;AAC9B,UAAM,QAAQ,SAAS,OAAO;AAC9B,QAAI,QAAQ,KAAK;AACf,YAAM;AACN,mBAAa;AAAA,IACf;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/math/random.ts"],"sourcesContent":["/**\n * Generate a random number within the given range.\n *\n * @param {number} minimum - The lower bound (inclusive).\n * @param {number} maximum - The upper bound (exclusive).\n * @returns {number} A random number between minimum (inclusive) and maximum (exclusive). The number can be an integer or a decimal.\n * @throws {Error} Throws an error if `maximum` is not greater than `minimum`.\n *\n * @example\n * const result1 = random(0, 5); // Returns a random number between 0 and 5.\n * const result2 = random(5, 0); // If the minimum is greater than the maximum, an error is thrown\n * const result3 = random(5, 5); // If the minimum is equal to the maximum, an error is thrown.\n */\nexport function random(minimum: number, maximum: number): number {\n if (minimum >= maximum) {\n throw new Error('Invalid input: The maximum value must be greater than the minimum value.');\n }\n\n return Math.random() * (maximum - minimum) + minimum;\n}\n"],"mappings":";AAaO,SAAS,OAAO,SAAiB,SAAyB;AAC/D,MAAI,WAAW,SAAS;AACtB,UAAM,IAAI,MAAM,0EAA0E;AAAA,EAC5F;AAEA,SAAO,KAAK,OAAO,KAAK,UAAU,WAAW;AAC/C;","names":[]}
|
package/dist/chunk-NP6PDX3E.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=chunk-NP6PDX3E.mjs.map
|
|
File without changes
|
|
File without changes
|