es-toolkit 1.15.0 → 1.15.1-dev.421
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 -0
- package/dist/array/index.js +9 -21
- package/dist/array/orderBy.mjs +9 -2
- package/package.json +1 -1
- package/dist/array/_internal/compareValues.mjs +0 -22
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# es-toolkit Changelog
|
|
2
2
|
|
|
3
|
+
## Version v1.15.1
|
|
4
|
+
|
|
5
|
+
Released on August 10th, 2024.
|
|
6
|
+
|
|
7
|
+
- Disabled implicit conversion of values in [orderBy](https://es-toolkit.slash.page/reference/array/orderBy.html) for performance and simplicity.
|
|
8
|
+
|
|
3
9
|
## Version v1.15.0
|
|
4
10
|
|
|
5
11
|
Released on August 10th, 2024.
|
package/dist/array/index.js
CHANGED
|
@@ -8,28 +8,16 @@ function flattenDeep(arr) {
|
|
|
8
8
|
return initial.flatten(arr, Infinity);
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
function compareValues(a, b, order) {
|
|
12
|
-
if (a === b) {
|
|
13
|
-
return 0;
|
|
14
|
-
}
|
|
15
|
-
if (a < b) {
|
|
16
|
-
return order === 'desc' ? 1 : -1;
|
|
17
|
-
}
|
|
18
|
-
if (a > b) {
|
|
19
|
-
return order === 'desc' ? -1 : 1;
|
|
20
|
-
}
|
|
21
|
-
if (typeof a === 'string' && typeof b === 'number') {
|
|
22
|
-
b = b.toString();
|
|
23
|
-
return compareValues(a, b, order);
|
|
24
|
-
}
|
|
25
|
-
if (typeof a === 'number' && typeof b === 'string') {
|
|
26
|
-
a = a.toString();
|
|
27
|
-
return compareValues(a, b, order);
|
|
28
|
-
}
|
|
29
|
-
return 0;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
11
|
function orderBy(collection, keys, orders) {
|
|
12
|
+
const compareValues = (a, b, order) => {
|
|
13
|
+
if (a < b) {
|
|
14
|
+
return order === 'asc' ? -1 : 1;
|
|
15
|
+
}
|
|
16
|
+
if (a > b) {
|
|
17
|
+
return order === 'asc' ? 1 : -1;
|
|
18
|
+
}
|
|
19
|
+
return 0;
|
|
20
|
+
};
|
|
33
21
|
const effectiveOrders = keys.map((_, index) => orders[index] || orders[orders.length - 1]);
|
|
34
22
|
return collection.slice().sort((a, b) => {
|
|
35
23
|
for (let i = 0; i < keys.length; i++) {
|
package/dist/array/orderBy.mjs
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import { compareValues } from './_internal/compareValues.mjs';
|
|
2
|
-
|
|
3
1
|
function orderBy(collection, keys, orders) {
|
|
2
|
+
const compareValues = (a, b, order) => {
|
|
3
|
+
if (a < b) {
|
|
4
|
+
return order === 'asc' ? -1 : 1;
|
|
5
|
+
}
|
|
6
|
+
if (a > b) {
|
|
7
|
+
return order === 'asc' ? 1 : -1;
|
|
8
|
+
}
|
|
9
|
+
return 0;
|
|
10
|
+
};
|
|
4
11
|
const effectiveOrders = keys.map((_, index) => orders[index] || orders[orders.length - 1]);
|
|
5
12
|
return collection.slice().sort((a, b) => {
|
|
6
13
|
for (let i = 0; i < keys.length; i++) {
|
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.15.
|
|
4
|
+
"version": "1.15.1-dev.421+0ae3e519",
|
|
5
5
|
"homepage": "https://es-toolkit.slash.page",
|
|
6
6
|
"bugs": "https://github.com/toss/es-toolkit/issues",
|
|
7
7
|
"repository": {
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
function compareValues(a, b, order) {
|
|
2
|
-
if (a === b) {
|
|
3
|
-
return 0;
|
|
4
|
-
}
|
|
5
|
-
if (a < b) {
|
|
6
|
-
return order === 'desc' ? 1 : -1;
|
|
7
|
-
}
|
|
8
|
-
if (a > b) {
|
|
9
|
-
return order === 'desc' ? -1 : 1;
|
|
10
|
-
}
|
|
11
|
-
if (typeof a === 'string' && typeof b === 'number') {
|
|
12
|
-
b = b.toString();
|
|
13
|
-
return compareValues(a, b, order);
|
|
14
|
-
}
|
|
15
|
-
if (typeof a === 'number' && typeof b === 'string') {
|
|
16
|
-
a = a.toString();
|
|
17
|
-
return compareValues(a, b, order);
|
|
18
|
-
}
|
|
19
|
-
return 0;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export { compareValues };
|