@longlast/equals 0.5.8 → 0.5.10

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/README.md CHANGED
@@ -32,4 +32,4 @@ equals(
32
32
 
33
33
  [Browse the docs on longlast.js.org][docs].
34
34
 
35
- [docs]: https://longlast.js.org/equals/
35
+ [docs]: https://longlast.js.org/reference/equals/
package/dist/index.d.ts CHANGED
@@ -53,9 +53,9 @@ export declare const equalsWith: Curried3<EqualsOptions, unknown, unknown, boole
53
53
  * - Maps are equal iff they have the same set of keys, and their
54
54
  * corresponding values are deeply equal. Note that map keys are _not_
55
55
  * deeply compared.
56
- * - Partially applied curried functions are equal iff they originate from
57
- * the same curried function and their bound arguments are equal
58
- * according to `equals`. See {@link curry}.
56
+ * - Partially applied functions (via {@link curry} or {@link partial-apply})
57
+ * are equal iff they originate from the same function and their bound
58
+ * arguments are equal according to `equals`.
59
59
  * - Other objects are equal iff they have the same prototype (e.g. the same
60
60
  * class) and the same set of enumerable string-keyed properties, and the
61
61
  * values of their corresponding properties are equal (according to
@@ -66,7 +66,7 @@ export declare const equalsWith: Curried3<EqualsOptions, unknown, unknown, boole
66
66
  * class. For example:
67
67
  *
68
68
  * ```ts
69
- * import {$equals} from "@longlast/symbols"
69
+ * import {$equals} from "@longlast/symbols";
70
70
  *
71
71
  * class HttpError extends Error {
72
72
  * private statusCode: number;
package/dist/index.js CHANGED
@@ -2,7 +2,8 @@
2
2
  * @module equals
3
3
  */
4
4
  import { curry } from "@longlast/curry";
5
- import { $boundArguments, $equals, $getBoundArguments, $unapplied, } from "@longlast/symbols";
5
+ import { getBoundArguments, getUnapplied } from "@longlast/function-provenance";
6
+ import { $equals } from "@longlast/symbols";
6
7
  /**
7
8
  * @function
8
9
  * A version of {@link equals} that allows callers to override the default
@@ -47,10 +48,9 @@ function _equalsWith(options, a, b) {
47
48
  return true;
48
49
  }
49
50
  if (typeof a === "function" && typeof b === "function") {
50
- const aUnapplied = a[$unapplied];
51
- const bUnapplied = b[$unapplied];
52
- return (aUnapplied != null &&
53
- aUnapplied === bUnapplied &&
51
+ unsafeNarrow(a);
52
+ unsafeNarrow(b);
53
+ return (getUnapplied(a) === getUnapplied(b) &&
54
54
  _equalsWith(options, getBoundArguments(a), getBoundArguments(b)));
55
55
  }
56
56
  // If `a` is a primitive at this point, return false, since we already know
@@ -142,9 +142,9 @@ function _equalsWith(options, a, b) {
142
142
  * - Maps are equal iff they have the same set of keys, and their
143
143
  * corresponding values are deeply equal. Note that map keys are _not_
144
144
  * deeply compared.
145
- * - Partially applied curried functions are equal iff they originate from
146
- * the same curried function and their bound arguments are equal
147
- * according to `equals`. See {@link curry}.
145
+ * - Partially applied functions (via {@link curry} or {@link partial-apply})
146
+ * are equal iff they originate from the same function and their bound
147
+ * arguments are equal according to `equals`.
148
148
  * - Other objects are equal iff they have the same prototype (e.g. the same
149
149
  * class) and the same set of enumerable string-keyed properties, and the
150
150
  * values of their corresponding properties are equal (according to
@@ -155,7 +155,7 @@ function _equalsWith(options, a, b) {
155
155
  * class. For example:
156
156
  *
157
157
  * ```ts
158
- * import {$equals} from "@longlast/symbols"
158
+ * import {$equals} from "@longlast/symbols";
159
159
  *
160
160
  * class HttpError extends Error {
161
161
  * private statusCode: number;
@@ -186,10 +186,6 @@ function _equalsWith(options, a, b) {
186
186
  */
187
187
  // TODO: clear function provenance on `equals`.
188
188
  export const equals = equalsWith({});
189
- function getBoundArguments(f) {
190
- // TODO: (pre-1.0.0) remove `f[$boundArguments]` fallback.
191
- return f[$getBoundArguments]?.() ?? f[$boundArguments];
192
- }
193
189
  function functionString(f) {
194
190
  if (typeof f !== "function") {
195
191
  return "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longlast/equals",
3
- "version": "0.5.8",
3
+ "version": "0.5.10",
4
4
  "description": "Deeply compares objects",
5
5
  "homepage": "https://longlast.js.org/",
6
6
  "license": "MIT",
@@ -17,8 +17,10 @@
17
17
  "#@longlast/equals": "./src/index.ts"
18
18
  },
19
19
  "dependencies": {
20
+ "@longlast/any-function": "^0.0.1",
20
21
  "@longlast/curry": "^0.5.0",
21
- "@longlast/symbols": "^1.0.0"
22
+ "@longlast/function-provenance": "^0.0.3",
23
+ "@longlast/symbols": "^1.1.0"
22
24
  },
23
25
  "devDependencies": {
24
26
  "fast-deep-equal": "3.1.3"