UNPKG

@monstermann/fn

Version:

A utility library for TypeScript.

24 lines (22 loc) 474 B
import { dfdlT } from "@monstermann/dfdl"; //#region src/object/hasKey.ts /** * `hasKey(target, key)` * * Checks if `target` object has the specified `key` property. * * ```ts * hasKey({ a: 1, b: 2 }, "a"); // true * hasKey({ a: 1, b: 2 }, "c"); // false * ``` * * ```ts * pipe({ a: 1, b: 2 }, hasKey("a")); // true * pipe({ a: 1, b: 2 }, hasKey("c")); // false * ``` */ const hasKey = dfdlT((target, key) => { return key in target; }, 2); //#endregion export { hasKey };