es-toolkit 1.39.7-dev.1443 → 1.39.7-dev.1459
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.
|
@@ -10,13 +10,13 @@ function unzipWith(array, iteratee) {
|
|
|
10
10
|
if (!isArrayLikeObject.isArrayLikeObject(array) || !array.length) {
|
|
11
11
|
return [];
|
|
12
12
|
}
|
|
13
|
-
const
|
|
13
|
+
const unzipped = isArray.isArray(array) ? unzip.unzip(array) : unzip.unzip(Array.from(array, value => Array.from(value)));
|
|
14
14
|
if (!iteratee) {
|
|
15
|
-
return
|
|
15
|
+
return unzipped;
|
|
16
16
|
}
|
|
17
|
-
const result = new Array(
|
|
18
|
-
for (let i = 0; i <
|
|
19
|
-
const value =
|
|
17
|
+
const result = new Array(unzipped.length);
|
|
18
|
+
for (let i = 0; i < unzipped.length; i++) {
|
|
19
|
+
const value = unzipped[i];
|
|
20
20
|
result[i] = iteratee(...value);
|
|
21
21
|
}
|
|
22
22
|
return result;
|
|
@@ -6,13 +6,13 @@ function unzipWith(array, iteratee) {
|
|
|
6
6
|
if (!isArrayLikeObject(array) || !array.length) {
|
|
7
7
|
return [];
|
|
8
8
|
}
|
|
9
|
-
const
|
|
9
|
+
const unzipped = isArray(array) ? unzip(array) : unzip(Array.from(array, value => Array.from(value)));
|
|
10
10
|
if (!iteratee) {
|
|
11
|
-
return
|
|
11
|
+
return unzipped;
|
|
12
12
|
}
|
|
13
|
-
const result = new Array(
|
|
14
|
-
for (let i = 0; i <
|
|
15
|
-
const value =
|
|
13
|
+
const result = new Array(unzipped.length);
|
|
14
|
+
for (let i = 0; i < unzipped.length; i++) {
|
|
15
|
+
const value = unzipped[i];
|
|
16
16
|
result[i] = iteratee(...value);
|
|
17
17
|
}
|
|
18
18
|
return result;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { ValueIteratee } from '../_internal/ValueIteratee.mjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Finds the element in an array that has the
|
|
4
|
+
* Finds the element in an array that has the minimum value when applying
|
|
5
5
|
* the `iteratee` to each element.
|
|
6
6
|
*
|
|
7
7
|
* @template T - The type of elements in the array.
|
|
8
8
|
* @param {T[]} items The array of elements to search.
|
|
9
9
|
* @param {((element: T) => number) | keyof T | [keyof T, unknown] | Partial<T>} iteratee
|
|
10
|
-
* The criteria used to determine the
|
|
10
|
+
* The criteria used to determine the minimum value.
|
|
11
11
|
* - If a **function** is provided, it extracts a numeric value from each element.
|
|
12
12
|
* - If a **string** is provided, it is treated as a key to extract values from the objects.
|
|
13
13
|
* - If a **[key, value]** pair is provided, it matches elements with the specified key-value pair.
|
|
14
14
|
* - If an **object** is provided, it matches elements that contain the specified properties.
|
|
15
|
-
* @returns {T | undefined} The element with the
|
|
15
|
+
* @returns {T | undefined} The element with the minimum value as determined by the `iteratee`.
|
|
16
16
|
* @example
|
|
17
17
|
* minBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 1 }
|
|
18
18
|
* minBy([], x => x.a); // Returns: undefined
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { ValueIteratee } from '../_internal/ValueIteratee.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Finds the element in an array that has the
|
|
4
|
+
* Finds the element in an array that has the minimum value when applying
|
|
5
5
|
* the `iteratee` to each element.
|
|
6
6
|
*
|
|
7
7
|
* @template T - The type of elements in the array.
|
|
8
8
|
* @param {T[]} items The array of elements to search.
|
|
9
9
|
* @param {((element: T) => number) | keyof T | [keyof T, unknown] | Partial<T>} iteratee
|
|
10
|
-
* The criteria used to determine the
|
|
10
|
+
* The criteria used to determine the minimum value.
|
|
11
11
|
* - If a **function** is provided, it extracts a numeric value from each element.
|
|
12
12
|
* - If a **string** is provided, it is treated as a key to extract values from the objects.
|
|
13
13
|
* - If a **[key, value]** pair is provided, it matches elements with the specified key-value pair.
|
|
14
14
|
* - If an **object** is provided, it matches elements that contain the specified properties.
|
|
15
|
-
* @returns {T | undefined} The element with the
|
|
15
|
+
* @returns {T | undefined} The element with the minimum value as determined by the `iteratee`.
|
|
16
16
|
* @example
|
|
17
17
|
* minBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 1 }
|
|
18
18
|
* minBy([], x => x.a); // Returns: undefined
|
package/dist/function/once.d.mts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Creates a function that is restricted to invoking func once. Repeat calls to the function return the value of the first invocation.
|
|
3
3
|
*
|
|
4
|
-
* @template
|
|
5
|
-
* @param {
|
|
6
|
-
* @returns {
|
|
4
|
+
* @template F - The type of the function.
|
|
5
|
+
* @param {F} func - The function to restrict.
|
|
6
|
+
* @returns {F} Returns the new restricted function.
|
|
7
7
|
*
|
|
8
8
|
* @example
|
|
9
|
-
*
|
|
9
|
+
* const initialize = once(createApplication);
|
|
10
|
+
*
|
|
10
11
|
* initialize();
|
|
11
12
|
* initialize();
|
|
12
13
|
* // => `createApplication` is invoked once
|
|
13
14
|
*/
|
|
14
|
-
declare function once<
|
|
15
|
+
declare function once<F extends (...args: any[]) => any>(func: F): F;
|
|
15
16
|
|
|
16
17
|
export { once };
|
package/dist/function/once.d.ts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Creates a function that is restricted to invoking func once. Repeat calls to the function return the value of the first invocation.
|
|
3
3
|
*
|
|
4
|
-
* @template
|
|
5
|
-
* @param {
|
|
6
|
-
* @returns {
|
|
4
|
+
* @template F - The type of the function.
|
|
5
|
+
* @param {F} func - The function to restrict.
|
|
6
|
+
* @returns {F} Returns the new restricted function.
|
|
7
7
|
*
|
|
8
8
|
* @example
|
|
9
|
-
*
|
|
9
|
+
* const initialize = once(createApplication);
|
|
10
|
+
*
|
|
10
11
|
* initialize();
|
|
11
12
|
* initialize();
|
|
12
13
|
* // => `createApplication` is invoked once
|
|
13
14
|
*/
|
|
14
|
-
declare function once<
|
|
15
|
+
declare function once<F extends (...args: any[]) => any>(func: F): F;
|
|
15
16
|
|
|
16
17
|
export { once };
|
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.39.7-dev.
|
|
4
|
+
"version": "1.39.7-dev.1459+cc46622a",
|
|
5
5
|
"homepage": "https://es-toolkit.dev",
|
|
6
6
|
"bugs": "https://github.com/toss/es-toolkit/issues",
|
|
7
7
|
"repository": {
|