New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
export eqStrict #965
export eqStrict #965
Comments
Because is meaningful only with primitives. The following function is not pure with respect to eqStrict interface Person {
name: string
}
function makePerson(name: string): Person {
return { name }
} |
Hmm, I am using |
It's still useful to have something like this for primitives, though. For instance, I've defined this in my fp-ts utilities: eq.ts export type StrictComparable = string | number | boolean;
// Untested, but could probably instead be type Primitive = string | number | bigint | boolean | null | undefined | symbol;
export const eqStrict = <A extends StrictComparable>() => eq.fromEquals<A>(eq.strictEqual);
export const byId = <A, B extends StrictComparable>(f: (a: A) => B) => eq.contramap(f)(eqStrict()); array.ts export function distinct<A extends StrictComparable>(): (as: A[]) => A[] {
return flow(array.uniq(eqStrict()));
}
export function distinctBy<A, B extends StrictComparable>(f: (a: A) => B): (as: A[]) => A[] {
return flow(array.uniq(byId(f)));
} |
Why
const eqStrict = { equals: strictEqual }
isn't exported? It seems it should be.The text was updated successfully, but these errors were encountered: