es-toolkit 1.47.0-dev.1828 → 1.47.0-dev.1829
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.
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
//#region src/_internal/compareValues.ts
|
|
2
|
-
function
|
|
3
|
-
if (
|
|
4
|
-
if (
|
|
2
|
+
function nullishRank(value) {
|
|
3
|
+
if (value === null) return 1;
|
|
4
|
+
if (value === void 0) return 2;
|
|
5
|
+
return 0;
|
|
6
|
+
}
|
|
7
|
+
function compareAscending(a, b) {
|
|
8
|
+
const aRank = nullishRank(a);
|
|
9
|
+
const bRank = nullishRank(b);
|
|
10
|
+
if (aRank < bRank) return -1;
|
|
11
|
+
if (aRank > bRank) return 1;
|
|
12
|
+
if (aRank !== 0) return 0;
|
|
13
|
+
if (a < b) return -1;
|
|
14
|
+
if (a > b) return 1;
|
|
5
15
|
return 0;
|
|
6
16
|
}
|
|
17
|
+
function compareValues(a, b, order) {
|
|
18
|
+
return order === "asc" ? compareAscending(a, b) : compareAscending(b, a);
|
|
19
|
+
}
|
|
7
20
|
//#endregion
|
|
8
21
|
exports.compareValues = compareValues;
|
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
//#region src/_internal/compareValues.ts
|
|
2
|
-
function
|
|
3
|
-
if (
|
|
4
|
-
if (
|
|
2
|
+
function nullishRank(value) {
|
|
3
|
+
if (value === null) return 1;
|
|
4
|
+
if (value === void 0) return 2;
|
|
5
|
+
return 0;
|
|
6
|
+
}
|
|
7
|
+
function compareAscending(a, b) {
|
|
8
|
+
const aRank = nullishRank(a);
|
|
9
|
+
const bRank = nullishRank(b);
|
|
10
|
+
if (aRank < bRank) return -1;
|
|
11
|
+
if (aRank > bRank) return 1;
|
|
12
|
+
if (aRank !== 0) return 0;
|
|
13
|
+
if (a < b) return -1;
|
|
14
|
+
if (a > b) return 1;
|
|
5
15
|
return 0;
|
|
6
16
|
}
|
|
17
|
+
function compareValues(a, b, order) {
|
|
18
|
+
return order === "asc" ? compareAscending(a, b) : compareAscending(b, a);
|
|
19
|
+
}
|
|
7
20
|
//#endregion
|
|
8
21
|
export { compareValues };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "es-toolkit",
|
|
3
|
-
"version": "1.47.0-dev.
|
|
3
|
+
"version": "1.47.0-dev.1829+031f8cf2",
|
|
4
4
|
"description": "A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.",
|
|
5
5
|
"homepage": "https://es-toolkit.dev",
|
|
6
6
|
"bugs": "https://github.com/toss/es-toolkit/issues",
|