@lou.codes/predicates
Version:
🧐 Predicate util functions
18 lines (17 loc) • 523 B
TypeScript
import type { Class } from "@lou.codes/types";
/**
* Takes a `constructor` and checks if given `input` is an instance of it.
*
* @category Objects
* @example
* ```typescript
* const instanceOfArray = instanceOf(Array)
*
* instanceOfArray([]); // true
* instanceOfArray({}); // false
* ```
* @returns Returns a curried function with `constructor` in context.
*/
export declare const isInstanceOf: <Expected extends Class<never>>(
constructor: Expected,
) => (input: unknown) => input is InstanceType<Expected>;