@longlast/equals 0.1.2 → 0.2.0

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
@@ -16,7 +16,9 @@
16
16
  * class) and the same set of enumerable string-keyed properties, and the
17
17
  * values of their corresponding properties are equal (according to
18
18
  * `equals`).
19
- * - Primitives `a` and `b` are equal iff `a === b`.
19
+ * - Primitives `a` and `b` are equal iff `Object.is(a, b)`. This is similar
20
+ * to `===` comparison, but treats `NaN` as equal to `NaN` and `0` as
21
+ * different from `-0`.
20
22
  *
21
23
  * `equals()` can throw a RangeError if one of its arguments contains a
22
24
  * reference cycle. Avoid passing mutable objects to `equals()` unless you know
package/dist/index.js CHANGED
@@ -16,14 +16,16 @@
16
16
  * class) and the same set of enumerable string-keyed properties, and the
17
17
  * values of their corresponding properties are equal (according to
18
18
  * `equals`).
19
- * - Primitives `a` and `b` are equal iff `a === b`.
19
+ * - Primitives `a` and `b` are equal iff `Object.is(a, b)`. This is similar
20
+ * to `===` comparison, but treats `NaN` as equal to `NaN` and `0` as
21
+ * different from `-0`.
20
22
  *
21
23
  * `equals()` can throw a RangeError if one of its arguments contains a
22
24
  * reference cycle. Avoid passing mutable objects to `equals()` unless you know
23
25
  * that they do not contain cycles.
24
26
  */
25
27
  export function equals(a, b) {
26
- if (a === b) {
28
+ if (Object.is(a, b)) {
27
29
  return true;
28
30
  }
29
31
  if (Array.isArray(a) && Array.isArray(b)) {
@@ -46,7 +48,7 @@ export function equals(a, b) {
46
48
  aKeys.every((k) => equals(a[k], b[k])) &&
47
49
  Object.getPrototypeOf(a) === Object.getPrototypeOf(b));
48
50
  }
49
- return a === b;
51
+ return false;
50
52
  }
51
53
  function isObject(x) {
52
54
  return !!x && typeof x === "object";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longlast/equals",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"