Function: equals()

Deeply compares two values, returning true if they're equal and false otherwise. The following criteria are used to determine equality:

You can customize how equals() compares values of a specific class by using the $equals symbol to define a method on that class. For example:

import {$equals} from "@longlast/symbols"

class HttpError extends Error {
    private statusCode: number;
    constructor(message: string, statusCode: number) {
        super(message);
        this.statusCode = statusCode;
    }

    [$equals](other: unknown) {
        return other instanceof HttpError &&
            other.statusCode === this.statusCode &&
            other.message === this.message;
    }
}

Note that this makes the comparison asymmetrical: a is considered equal to b iff a[$equals](b) returns truthy. The $equals method will always be called on the first argument to equals().

equals() is curried. See curry.

Limitations

equals() can throw a RangeError if one of its arguments contains a reference cycle. Avoid passing mutable objects to equals() unless you know that they do not contain cycles.

Call Signature

equals(a: unknown, b: unknown): boolean

Defined in: node_modules/.pnpm/@longlast+curry@0.4.0/node_modules/@longlast/curry/dist/index.d.ts:41

Parameters

Parameter Type
a unknown
b unknown

Returns

boolean

Call Signature

equals(a: unknown): Curried1<unknown, boolean>

Defined in: node_modules/.pnpm/@longlast+curry@0.4.0/node_modules/@longlast/curry/dist/index.d.ts:41

Parameters

Parameter Type
a unknown

Returns

Curried1<unknown, boolean>