@longlast/equals 0.3.0 → 0.4.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.
@@ -0,0 +1,7 @@
1
+ type Func2<A, B, Out> = (a: A, b: B) => Out;
2
+ export interface Curried2<A, B, Out> {
3
+ (a: A, b: B): Out;
4
+ (a: A): (b: B) => Out;
5
+ }
6
+ export declare function curry<A, B, Out>(f: Func2<A, B, Out>): Curried2<A, B, Out>;
7
+ export {};
package/dist/curry.js ADDED
@@ -0,0 +1,12 @@
1
+ export function curry(f) {
2
+ return function (a, b) {
3
+ if (arguments.length === f.length) {
4
+ return f(a, b);
5
+ }
6
+ else {
7
+ return function (b) {
8
+ return f(a, b);
9
+ };
10
+ }
11
+ };
12
+ }
package/dist/index.d.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  /**
2
2
  * @module equals
3
3
  */
4
+ import { type Curried2 } from "./curry.ts";
4
5
  /**
6
+ * @function
5
7
  * Deeply compares two values, returning true if they're equal and false
6
8
  * otherwise. The following criteria are used to determine equality:
7
9
  *
@@ -24,5 +26,7 @@
24
26
  * `equals()` can throw a `RangeError` if one of its arguments contains a
25
27
  * reference cycle. Avoid passing mutable objects to `equals()` unless you know
26
28
  * that they do not contain cycles.
29
+ *
30
+ * `equals()` is curried.
27
31
  */
28
- export declare function equals(a: unknown, b: unknown): boolean;
32
+ export declare const equals: Curried2<unknown, unknown, boolean>;
package/dist/index.js CHANGED
@@ -1,7 +1,9 @@
1
1
  /**
2
2
  * @module equals
3
3
  */
4
+ import { curry } from "./curry.js";
4
5
  /**
6
+ * @function
5
7
  * Deeply compares two values, returning true if they're equal and false
6
8
  * otherwise. The following criteria are used to determine equality:
7
9
  *
@@ -24,8 +26,11 @@
24
26
  * `equals()` can throw a `RangeError` if one of its arguments contains a
25
27
  * reference cycle. Avoid passing mutable objects to `equals()` unless you know
26
28
  * that they do not contain cycles.
29
+ *
30
+ * `equals()` is curried.
27
31
  */
28
- export function equals(a, b) {
32
+ export const equals = curry(_equals);
33
+ function _equals(a, b) {
29
34
  if (Object.is(a, b)) {
30
35
  return true;
31
36
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longlast/equals",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"