es-toolkit 1.4.0-dev.92 → 1.4.0-dev.94
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/differenceWith.js.map +1 -1
- package/dist/array/differenceWith.mjs +1 -1
- package/dist/array/dropRightWhile.js.map +1 -1
- package/dist/array/dropRightWhile.mjs +2 -2
- package/dist/array/dropWhile.js.map +1 -1
- package/dist/array/dropWhile.mjs +1 -1
- package/dist/array/index.js.map +1 -1
- package/dist/array/index.mjs +41 -41
- package/dist/array/intersectionWith.js.map +1 -1
- package/dist/array/intersectionWith.mjs +1 -1
- package/dist/array/unionWith.js.map +1 -1
- package/dist/array/unionWith.mjs +1 -1
- package/dist/array/xorWith.js.map +1 -1
- package/dist/array/xorWith.mjs +4 -4
- package/dist/array/zip.js.map +1 -1
- package/dist/array/zip.mjs +1 -1
- package/dist/array/zipWith.js.map +1 -1
- package/dist/array/zipWith.mjs +1 -1
- package/dist/{chunk-KLJRZJOR.mjs → chunk-2EFS3VA3.mjs} +1 -1
- package/dist/{chunk-KLJRZJOR.mjs.map → chunk-2EFS3VA3.mjs.map} +1 -1
- package/dist/{chunk-T5FDOBCA.mjs → chunk-4KYXHZ4R.mjs} +1 -1
- package/dist/{chunk-T5FDOBCA.mjs.map → chunk-4KYXHZ4R.mjs.map} +1 -1
- package/dist/{chunk-3KHI4I2X.mjs → chunk-642SWVKJ.mjs} +1 -1
- package/dist/{chunk-3KHI4I2X.mjs.map → chunk-642SWVKJ.mjs.map} +1 -1
- package/dist/{chunk-FQ4K36VD.mjs → chunk-6NVQAHXP.mjs} +1 -1
- package/dist/{chunk-FQ4K36VD.mjs.map → chunk-6NVQAHXP.mjs.map} +1 -1
- package/dist/{chunk-DD73BULA.mjs → chunk-IDCUZVJL.mjs} +1 -1
- package/dist/{chunk-DD73BULA.mjs.map → chunk-IDCUZVJL.mjs.map} +1 -1
- package/dist/{chunk-JFHM6EY2.mjs → chunk-K2BAFL2T.mjs} +1 -1
- package/dist/{chunk-JFHM6EY2.mjs.map → chunk-K2BAFL2T.mjs.map} +1 -1
- package/dist/{chunk-CIRFWC7Y.mjs → chunk-RNJM5BHX.mjs} +2 -2
- package/dist/{chunk-VZUJ5PIA.mjs → chunk-SAL5OUAE.mjs} +1 -1
- package/dist/{chunk-VZUJ5PIA.mjs.map → chunk-SAL5OUAE.mjs.map} +1 -1
- package/dist/{chunk-FCF2RHPW.mjs → chunk-UMDNWTJC.mjs} +4 -4
- package/dist/{chunk-FCF2RHPW.mjs.map → chunk-UMDNWTJC.mjs.map} +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +54 -54
- package/dist/math/index.js.map +1 -1
- package/dist/math/index.mjs +1 -1
- package/dist/math/minBy.js.map +1 -1
- package/dist/math/minBy.mjs +1 -1
- package/package.json +3 -1
- /package/dist/{chunk-CIRFWC7Y.mjs.map → chunk-RNJM5BHX.mjs.map} +0 -0
package/dist/index.mjs
CHANGED
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
} from "./chunk-6E6PBLFK.mjs";
|
|
22
22
|
import {
|
|
23
23
|
minBy
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-SAL5OUAE.mjs";
|
|
25
25
|
import {
|
|
26
26
|
randomInt
|
|
27
27
|
} from "./chunk-QWJDITYJ.mjs";
|
|
@@ -47,62 +47,50 @@ import {
|
|
|
47
47
|
import {
|
|
48
48
|
pickBy
|
|
49
49
|
} from "./chunk-MQWVBKUT.mjs";
|
|
50
|
-
import "./chunk-
|
|
50
|
+
import "./chunk-N6EM6ETS.mjs";
|
|
51
51
|
import {
|
|
52
|
-
|
|
53
|
-
} from "./chunk-
|
|
52
|
+
debounce
|
|
53
|
+
} from "./chunk-MKETZ2RP.mjs";
|
|
54
54
|
import {
|
|
55
|
-
|
|
56
|
-
} from "./chunk-
|
|
57
|
-
import "./chunk-EJGAXTF7.mjs";
|
|
55
|
+
noop
|
|
56
|
+
} from "./chunk-LKXCOLNY.mjs";
|
|
58
57
|
import {
|
|
59
|
-
|
|
60
|
-
} from "./chunk-
|
|
58
|
+
once
|
|
59
|
+
} from "./chunk-UFAA5WKR.mjs";
|
|
61
60
|
import {
|
|
62
|
-
|
|
63
|
-
} from "./chunk-
|
|
61
|
+
throttle
|
|
62
|
+
} from "./chunk-XLO3QZVY.mjs";
|
|
64
63
|
import {
|
|
65
|
-
|
|
66
|
-
} from "./chunk-
|
|
64
|
+
clamp
|
|
65
|
+
} from "./chunk-MLCL773E.mjs";
|
|
66
|
+
import "./chunk-EJGAXTF7.mjs";
|
|
67
67
|
import {
|
|
68
68
|
zip
|
|
69
|
-
} from "./chunk-
|
|
69
|
+
} from "./chunk-IDCUZVJL.mjs";
|
|
70
70
|
import {
|
|
71
71
|
zipWith
|
|
72
|
-
} from "./chunk-
|
|
72
|
+
} from "./chunk-4KYXHZ4R.mjs";
|
|
73
73
|
import {
|
|
74
|
-
|
|
75
|
-
} from "./chunk-
|
|
74
|
+
uniqBy
|
|
75
|
+
} from "./chunk-WPDDOUQT.mjs";
|
|
76
76
|
import {
|
|
77
|
-
|
|
78
|
-
} from "./chunk-
|
|
77
|
+
xor
|
|
78
|
+
} from "./chunk-WXIBCOES.mjs";
|
|
79
79
|
import {
|
|
80
|
-
|
|
81
|
-
} from "./chunk-
|
|
80
|
+
xorBy
|
|
81
|
+
} from "./chunk-AM2EGFCU.mjs";
|
|
82
82
|
import {
|
|
83
83
|
unionBy
|
|
84
84
|
} from "./chunk-NRNKP6JF.mjs";
|
|
85
85
|
import {
|
|
86
|
-
|
|
87
|
-
} from "./chunk-
|
|
88
|
-
import {
|
|
89
|
-
uniq
|
|
90
|
-
} from "./chunk-XFCW7XJ4.mjs";
|
|
86
|
+
xorWith
|
|
87
|
+
} from "./chunk-UMDNWTJC.mjs";
|
|
91
88
|
import {
|
|
92
|
-
|
|
93
|
-
} from "./chunk-
|
|
89
|
+
unionWith
|
|
90
|
+
} from "./chunk-642SWVKJ.mjs";
|
|
94
91
|
import {
|
|
95
92
|
uniqWith
|
|
96
93
|
} from "./chunk-2PFDLYQC.mjs";
|
|
97
|
-
import {
|
|
98
|
-
intersection
|
|
99
|
-
} from "./chunk-PYLGHB3F.mjs";
|
|
100
|
-
import {
|
|
101
|
-
intersectionBy
|
|
102
|
-
} from "./chunk-GNSJP2AB.mjs";
|
|
103
|
-
import {
|
|
104
|
-
intersectionWith
|
|
105
|
-
} from "./chunk-KLJRZJOR.mjs";
|
|
106
94
|
import {
|
|
107
95
|
partition
|
|
108
96
|
} from "./chunk-5L2V7WD3.mjs";
|
|
@@ -119,45 +107,57 @@ import {
|
|
|
119
107
|
takeRight
|
|
120
108
|
} from "./chunk-XDKEPIUV.mjs";
|
|
121
109
|
import {
|
|
122
|
-
|
|
123
|
-
} from "./chunk-
|
|
110
|
+
takeRightWhile
|
|
111
|
+
} from "./chunk-NTLX2MPV.mjs";
|
|
124
112
|
import {
|
|
125
|
-
|
|
126
|
-
} from "./chunk-
|
|
113
|
+
takeWhile
|
|
114
|
+
} from "./chunk-2IXFGSUA.mjs";
|
|
127
115
|
import {
|
|
128
|
-
|
|
129
|
-
} from "./chunk-
|
|
116
|
+
union
|
|
117
|
+
} from "./chunk-DAJZ3JCI.mjs";
|
|
118
|
+
import {
|
|
119
|
+
uniq
|
|
120
|
+
} from "./chunk-XFCW7XJ4.mjs";
|
|
130
121
|
import {
|
|
131
122
|
dropRight
|
|
132
123
|
} from "./chunk-Q75KEFW5.mjs";
|
|
133
124
|
import {
|
|
134
125
|
dropRightWhile
|
|
135
|
-
} from "./chunk-
|
|
126
|
+
} from "./chunk-RNJM5BHX.mjs";
|
|
136
127
|
import {
|
|
137
128
|
dropWhile
|
|
138
|
-
} from "./chunk-
|
|
129
|
+
} from "./chunk-K2BAFL2T.mjs";
|
|
139
130
|
import {
|
|
140
131
|
groupBy
|
|
141
132
|
} from "./chunk-LWXZFXY5.mjs";
|
|
142
|
-
import "./chunk-N6EM6ETS.mjs";
|
|
143
133
|
import {
|
|
144
|
-
|
|
145
|
-
} from "./chunk-
|
|
134
|
+
intersection
|
|
135
|
+
} from "./chunk-PYLGHB3F.mjs";
|
|
146
136
|
import {
|
|
147
|
-
|
|
148
|
-
} from "./chunk-
|
|
137
|
+
intersectionBy
|
|
138
|
+
} from "./chunk-GNSJP2AB.mjs";
|
|
149
139
|
import {
|
|
150
|
-
|
|
151
|
-
} from "./chunk-
|
|
140
|
+
intersectionWith
|
|
141
|
+
} from "./chunk-2EFS3VA3.mjs";
|
|
142
|
+
import "./chunk-FZEZH22H.mjs";
|
|
152
143
|
import {
|
|
153
|
-
|
|
154
|
-
} from "./chunk-
|
|
144
|
+
AbortError
|
|
145
|
+
} from "./chunk-VP2LXY75.mjs";
|
|
155
146
|
import {
|
|
156
147
|
chunk
|
|
157
148
|
} from "./chunk-E6C5EZQA.mjs";
|
|
158
149
|
import {
|
|
159
150
|
difference
|
|
160
151
|
} from "./chunk-M7UI5ETO.mjs";
|
|
152
|
+
import {
|
|
153
|
+
differenceBy
|
|
154
|
+
} from "./chunk-LVWX5B43.mjs";
|
|
155
|
+
import {
|
|
156
|
+
differenceWith
|
|
157
|
+
} from "./chunk-6NVQAHXP.mjs";
|
|
158
|
+
import {
|
|
159
|
+
drop
|
|
160
|
+
} from "./chunk-ACFP3XMB.mjs";
|
|
161
161
|
import "./chunk-2MM5EJJX.mjs";
|
|
162
162
|
export {
|
|
163
163
|
AbortError,
|
package/dist/math/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/math/index.ts","../../src/math/clamp.ts","../../src/math/random.ts","../../src/math/randomInt.ts","../../src/math/round.ts","../../src/math/sum.ts","../../src/math/maxBy.ts","../../src/math/minBy.ts"],"sourcesContent":["export { clamp } from './clamp';\nexport { random } from './random';\nexport { randomInt } from './randomInt';\nexport { round } from './round';\nexport { sum } from './sum';\nexport { maxBy } from './maxBy';\nexport { minBy } from './minBy';\n","/**\n * Clamps a number within the inclusive lower and upper bounds.\n *\n * This function takes a number and two bounds, and returns the number clamped within the specified bounds.\n * If only one bound is provided, it returns the minimum of the value and the bound.\n *\n * @param {number} value - The number to clamp.\n * @param {number} minimum - The minimum bound to clamp the number.\n * @param {number} maximum - The maximum bound to clamp the number.\n * @returns {number} The clamped number within the specified bounds.\n *\n * @example\n * const result1 = clamp(10, 5); // result1 will be 5, as 10 is clamped to the bound 5\n * const result2 = clamp(10, 5, 15); // result2 will be 10, as it is within the bounds 5 and 15\n * const result3 = clamp(2, 5, 15); // result3 will be 5, as 2 is clamped to the lower bound 5\n * const result4 = clamp(20, 5, 15); // result4 will be 15, as 20 is clamped to the upper bound 15\n */\nexport function clamp(value: number, maximum: number): number;\nexport function clamp(value: number, minimum: number, maximum: number): number;\nexport function clamp(value: number, bound1: number, bound2?: number): number {\n if (bound2 == null) {\n return Math.min(value, bound1);\n }\n\n return Math.min(Math.max(value, bound1), bound2);\n}\n","/**\n * Generates a random floating-point number between minimum (inclusive) and maximum (exclusive).\n * If min is greater than maximum, the values are swapped.\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 = random(0, 5); // result will be a random floating-point number between 0 (inclusive) and 5 (exclusive)\n * const result2 = random(5, 0); // This will throw an error\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","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","/**\n * Rounds a number to a specified precision.\n *\n * This function takes a number and an optional precision value, and returns the number rounded\n * to the specified number of decimal places.\n *\n * @param {number} value - The number to round.\n * @param {number} [precision=0] - The number of decimal places to round to. Defaults to 0.\n * @returns {number} The rounded number.\n *\n * @example\n * const result1 = round(1.2345); // result1 will be 1\n * const result2 = round(1.2345, 2); // result2 will be 1.23\n * const result3 = round(1.2345, 3); // result3 will be 1.235\n */\nexport function round(value: number, precision = 0): number {\n const multiplier = Math.pow(10, precision);\n return Math.round(value * multiplier) / multiplier;\n}\n","/**\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","/**\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","/**\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
|
|
1
|
+
{"version":3,"sources":["../../src/math/index.ts","../../src/math/clamp.ts","../../src/math/random.ts","../../src/math/randomInt.ts","../../src/math/round.ts","../../src/math/sum.ts","../../src/math/maxBy.ts","../../src/math/minBy.ts"],"sourcesContent":["export { clamp } from './clamp';\nexport { random } from './random';\nexport { randomInt } from './randomInt';\nexport { round } from './round';\nexport { sum } from './sum';\nexport { maxBy } from './maxBy';\nexport { minBy } from './minBy';\n","/**\n * Clamps a number within the inclusive lower and upper bounds.\n *\n * This function takes a number and two bounds, and returns the number clamped within the specified bounds.\n * If only one bound is provided, it returns the minimum of the value and the bound.\n *\n * @param {number} value - The number to clamp.\n * @param {number} minimum - The minimum bound to clamp the number.\n * @param {number} maximum - The maximum bound to clamp the number.\n * @returns {number} The clamped number within the specified bounds.\n *\n * @example\n * const result1 = clamp(10, 5); // result1 will be 5, as 10 is clamped to the bound 5\n * const result2 = clamp(10, 5, 15); // result2 will be 10, as it is within the bounds 5 and 15\n * const result3 = clamp(2, 5, 15); // result3 will be 5, as 2 is clamped to the lower bound 5\n * const result4 = clamp(20, 5, 15); // result4 will be 15, as 20 is clamped to the upper bound 15\n */\nexport function clamp(value: number, maximum: number): number;\nexport function clamp(value: number, minimum: number, maximum: number): number;\nexport function clamp(value: number, bound1: number, bound2?: number): number {\n if (bound2 == null) {\n return Math.min(value, bound1);\n }\n\n return Math.min(Math.max(value, bound1), bound2);\n}\n","/**\n * Generates a random floating-point number between minimum (inclusive) and maximum (exclusive).\n * If min is greater than maximum, the values are swapped.\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 = random(0, 5); // result will be a random floating-point number between 0 (inclusive) and 5 (exclusive)\n * const result2 = random(5, 0); // This will throw an error\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","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","/**\n * Rounds a number to a specified precision.\n *\n * This function takes a number and an optional precision value, and returns the number rounded\n * to the specified number of decimal places.\n *\n * @param {number} value - The number to round.\n * @param {number} [precision=0] - The number of decimal places to round to. Defaults to 0.\n * @returns {number} The rounded number.\n *\n * @example\n * const result1 = round(1.2345); // result1 will be 1\n * const result2 = round(1.2345, 2); // result2 will be 1.23\n * const result3 = round(1.2345, 3); // result3 will be 1.235\n */\nexport function round(value: number, precision = 0): number {\n const multiplier = Math.pow(10, precision);\n return Math.round(value * multiplier) / multiplier;\n}\n","/**\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","/**\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","/**\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":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACmBO,SAAS,MAAM,OAAe,QAAgB,QAAyB;AAC5E,MAAI,UAAU,MAAM;AAClB,WAAO,KAAK,IAAI,OAAO,MAAM;AAAA,EAC/B;AAEA,SAAO,KAAK,IAAI,KAAK,IAAI,OAAO,MAAM,GAAG,MAAM;AACjD;;;ACZO,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;;;ACLO,SAAS,UAAU,SAAiB,SAAyB;AAClE,SAAO,KAAK,MAAM,OAAO,SAAS,OAAO,CAAC;AAC5C;;;ACDO,SAAS,MAAM,OAAe,YAAY,GAAW;AAC1D,QAAM,aAAa,KAAK,IAAI,IAAI,SAAS;AACzC,SAAO,KAAK,MAAM,QAAQ,UAAU,IAAI;AAC1C;;;ACLO,SAAS,IAAI,MAAwB;AAC1C,MAAI,SAAS;AAEb,aAAW,OAAO,MAAM;AACtB,cAAU;AAAA,EACZ;AAEA,SAAO;AACT;;;ACHO,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;;;ACrBO,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/math/index.mjs
CHANGED
package/dist/math/minBy.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/math/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
|
|
1
|
+
{"version":3,"sources":["../../src/math/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":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;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/math/minBy.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "es-toolkit",
|
|
3
3
|
"description": "A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.",
|
|
4
|
-
"version": "1.4.0-dev.
|
|
4
|
+
"version": "1.4.0-dev.94+cfc47e4b",
|
|
5
5
|
"workspaces": [
|
|
6
6
|
"docs"
|
|
7
7
|
],
|
|
@@ -168,6 +168,7 @@
|
|
|
168
168
|
"@babel/preset-typescript": "^7.24.1",
|
|
169
169
|
"@changesets/changelog-github": "^0.5.0",
|
|
170
170
|
"@changesets/cli": "^2.27.1",
|
|
171
|
+
"@codspeed/vitest-plugin": "^3.1.0",
|
|
171
172
|
"@types/babel__core": "^7",
|
|
172
173
|
"@types/babel__preset-env": "^7",
|
|
173
174
|
"@types/broken-link-checker": "^0",
|
|
@@ -190,6 +191,7 @@
|
|
|
190
191
|
"prepack": "yarn build",
|
|
191
192
|
"build": "tsup && ./.scripts/postbuild.sh",
|
|
192
193
|
"test": "vitest run --coverage --typecheck",
|
|
194
|
+
"bench": "vitest bench",
|
|
193
195
|
"lint": "eslint ./src --ext .ts",
|
|
194
196
|
"format": "prettier --write ."
|
|
195
197
|
},
|
|
File without changes
|