@longlast/equals 0.5.0 → 0.5.1

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/index.d.ts CHANGED
@@ -7,7 +7,7 @@ import { type Curried2 } from "@longlast/curry";
7
7
  * Deeply compares two values, returning true if they're equal and false
8
8
  * otherwise. The following criteria are used to determine equality:
9
9
  *
10
- * - All values are always equal to themselves.
10
+ * - All values are equal to themselves.
11
11
  * - Primitives `a` and `b` are equal iff `Object.is(a, b)`. This is similar
12
12
  * to `===` comparison, but treats `NaN` as equal to `NaN` and `0` as
13
13
  * different from `-0`.
@@ -27,8 +27,8 @@ import { type Curried2 } from "@longlast/curry";
27
27
  * `equals`).
28
28
  *
29
29
  * You can customize how `equals()` compares values of a specific class by
30
- * using the {@link symbols.$equals $equals} symbol to define a method on that class. For
31
- * example:
30
+ * using the {@link symbols.$equals $equals} symbol to define a method on that
31
+ * class. For example:
32
32
  *
33
33
  * ```ts
34
34
  * import {$equals} from "@longlast/symbols"
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@ import { $boundArguments, $equals, $unapplied } from "@longlast/symbols";
8
8
  * Deeply compares two values, returning true if they're equal and false
9
9
  * otherwise. The following criteria are used to determine equality:
10
10
  *
11
- * - All values are always equal to themselves.
11
+ * - All values are equal to themselves.
12
12
  * - Primitives `a` and `b` are equal iff `Object.is(a, b)`. This is similar
13
13
  * to `===` comparison, but treats `NaN` as equal to `NaN` and `0` as
14
14
  * different from `-0`.
@@ -28,8 +28,8 @@ import { $boundArguments, $equals, $unapplied } from "@longlast/symbols";
28
28
  * `equals`).
29
29
  *
30
30
  * You can customize how `equals()` compares values of a specific class by
31
- * using the {@link symbols.$equals $equals} symbol to define a method on that class. For
32
- * example:
31
+ * using the {@link symbols.$equals $equals} symbol to define a method on that
32
+ * class. For example:
33
33
  *
34
34
  * ```ts
35
35
  * import {$equals} from "@longlast/symbols"
@@ -65,12 +65,12 @@ export const equals = curry(_equals);
65
65
  function _equals(a, b) {
66
66
  // This is an optimized implementation. There is a simpler, equivalent one
67
67
  // in pkg/equals/alt/reference.ts.
68
- if (Object.is(a, b)) {
69
- return true;
70
- }
71
68
  if (a != null && typeof a[$equals] === "function") {
72
69
  return Boolean(a[$equals](b));
73
70
  }
71
+ if (Object.is(a, b)) {
72
+ return true;
73
+ }
74
74
  if (a instanceof Date && b instanceof Date) {
75
75
  return Object.is(+a, +b);
76
76
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longlast/equals",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Deeply compares objects",
5
5
  "license": "MIT",
6
6
  "author": "Ben Christel (https://benchristel.com/)",