@lou.codes/predicates
Version:
🧐 Predicate util functions
18 lines (17 loc) • 584 B
JavaScript
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);