-
-
Notifications
You must be signed in to change notification settings - Fork 0
keyof
Nicholas Berlette edited this page Jun 19, 2025
·
1 revision
function isKeyOf<T extends {}, K extends PropertyKey = keyof T>(
o: T,
k: K,
): k is K & keyof T;Objects
import { isKeyOf } from "jsr:@nick/is/keyof";
const obj = { a: 1, b: 2, c: 3 };
console.log(isKeyOf(obj, "a")); // true
console.log(isKeyOf(obj, "b")); // true
console.log(isKeyOf(obj, "c")); // true
console.log(isKeyOf(obj, "d")); // false