@lou.codes/predicates
Version:
🧐 Predicate util functions
17 lines (16 loc) • 506 B
JavaScript
import { hasOwn } from "@lou.codes/constants/Object.js";
/**
* Check if the given key is present in the given object (not inherited).
*
* @category Predicates
* @category Objects
* @example
* ```typescript
* const isPropertyOfFoo = isPropertyOf({ "🟢": "🟩" });
* isPropertyOfFoo("🟢"); // true
* isPropertyOfFoo("🟩"); // false
* ```
* @param object Object to check.
* @returns Curried function with `context` set.
*/
export const isPropertyOf = object => key => hasOwn(object, key);