UNPKG

@monstermann/fn

Version:

A utility library for TypeScript.

31 lines (29 loc) 607 B
import { dfdlT } from "@monstermann/dfdl"; //#region src/object/test.ts /** * `test(target, key, predicate)` * * Checks if the `key` property of `target` object passes the `predicate` function test. * * ```ts * test({ a: 5, b: 2 }, "a", (x) => x > 3); // true * test({ a: 1, b: 2 }, "a", (x) => x > 3); // false * ``` * * ```ts * pipe( * { a: 5, b: 2 }, * test("a", (x) => x > 3), * ); // true * * pipe( * { a: 1, b: 2 }, * test("a", (x) => x > 3), * ); // false * ``` */ const test = dfdlT((target, key, predicate) => { return predicate(target[key]); }, 3); //#endregion export { test };