import { eq } from "https://deno.land/x/fun@v2.0.0-alpha.6/mod.ts";
const { method } = eq;
Create a eq from a method on a class or prototypical object. This exists because many objects in javascript do now allow you to pass an object method around on its own without its parent object. For example, if you pass Date.valueOf (type () => number) into another function and call it, the call will fail because valueOf does not carry the reference of its parent object around.
Examples
Example 1
Example 1
import { method, number } from "./eq.ts";
// This eq will work for date, but also for any objects that have
// a valueOf method that returns a number.
const date = method("valueOf", number);
const now = new Date();
const alsoNow = new Date(Date.now());
const later = new Date(Date.now() + 60 * 60 * 1000);
const result1 = date.equals(now)(alsoNow); // true
const result2 = date.equals(now)(later); // false