UNPKG

@lou.codes/predicates

Version:
18 lines (17 loc) 584 B
import { getPrototypeOf } from "@lou.codes/constants/Object.js"; /** * Checks if given `input`'s prototype comes directly from given `constructor`. * * @category Predicates * @category Objects * @example * ```typescript * const isPrototypeOfObject = isPrototypeOf(Object); * isPrototypeOfObject({}); // true * isPrototypeOfObject(/./); // false * ``` * @param constructor Constructor to check. * @returns Returns a curried function with `constructor` in context. */ export const isPrototypeOf = constructor => object => constructor.prototype === getPrototypeOf(object);