es-toolkit 1.47.0-dev.1827 → 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 compareValues(a, b, order) {
3
- if (a < b) return order === "asc" ? -1 : 1;
4
- if (a > b) return order === "asc" ? 1 : -1;
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 compareValues(a, b, order) {
3
- if (a < b) return order === "asc" ? -1 : 1;
4
- if (a > b) return order === "asc" ? 1 : -1;
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 };
@@ -15,10 +15,12 @@
15
15
  * const value1 = 123;
16
16
  * const value2 = 'abc';
17
17
  * const value3 = true;
18
+ * const value4 = new Number(42);
18
19
  *
19
20
  * console.log(isNumber(value1)); // true
20
21
  * console.log(isNumber(value2)); // false
21
22
  * console.log(isNumber(value3)); // false
23
+ * console.log(isNumber(value4)); // false
22
24
  *
23
25
  */
24
26
  declare function isNumber(x: unknown): x is number;
@@ -15,10 +15,12 @@
15
15
  * const value1 = 123;
16
16
  * const value2 = 'abc';
17
17
  * const value3 = true;
18
+ * const value4 = new Number(42);
18
19
  *
19
20
  * console.log(isNumber(value1)); // true
20
21
  * console.log(isNumber(value2)); // false
21
22
  * console.log(isNumber(value3)); // false
23
+ * console.log(isNumber(value4)); // false
22
24
  *
23
25
  */
24
26
  declare function isNumber(x: unknown): x is number;
@@ -15,14 +15,16 @@
15
15
  * const value1 = 123;
16
16
  * const value2 = 'abc';
17
17
  * const value3 = true;
18
+ * const value4 = new Number(42);
18
19
  *
19
20
  * console.log(isNumber(value1)); // true
20
21
  * console.log(isNumber(value2)); // false
21
22
  * console.log(isNumber(value3)); // false
23
+ * console.log(isNumber(value4)); // false
22
24
  *
23
25
  */
24
26
  function isNumber(x) {
25
- return typeof x === "number" || x instanceof Number;
27
+ return typeof x === "number";
26
28
  }
27
29
  //#endregion
28
30
  exports.isNumber = isNumber;
@@ -15,14 +15,16 @@
15
15
  * const value1 = 123;
16
16
  * const value2 = 'abc';
17
17
  * const value3 = true;
18
+ * const value4 = new Number(42);
18
19
  *
19
20
  * console.log(isNumber(value1)); // true
20
21
  * console.log(isNumber(value2)); // false
21
22
  * console.log(isNumber(value3)); // false
23
+ * console.log(isNumber(value4)); // false
22
24
  *
23
25
  */
24
26
  function isNumber(x) {
25
- return typeof x === "number" || x instanceof Number;
27
+ return typeof x === "number";
26
28
  }
27
29
  //#endregion
28
30
  export { isNumber };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "es-toolkit",
3
- "version": "1.47.0-dev.1827+34fb8e33",
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",