typedash
Version:
modern, type-safe collection of utility functions
20 lines (19 loc) • 521 B
JavaScript
//#region src/functions/hasKey/hasKey.ts
/**
* Returns whether the input value has the specified key.
* @param value The value to check.
* @param key The key to check for.
* @returns Whether the input value has the specified key.
* @example
* ```ts
* hasKey({ a: 1 }, 'a') // true
* hasKey({ a: 1 }, 'b') // false
* ```
*/
function hasKey(value, key) {
if (typeof value !== "object" || value == null) return false;
return key in value;
}
//#endregion
export { hasKey as t };
//# sourceMappingURL=hasKey-CJQn8BcL.js.map