Skip to content

by

by<A, B>(f): (eq) => Equality<B>

Defined in: Core/Equality.ts:81

Adapts an equality for type A into an equality for type B by extracting a field. Read as “equality by this field”: pipe(Equality.string, Equality.by(u => u.name)).

A

B

(b) => A

(eq) => Equality<B>

type Product = { id: string; price: number };
const byId = pipe(Equality.string, Equality.by((p: Product) => p.id));
byId({ id: "p1", price: 9 }, { id: "p1", price: 12 }); // true