typedash
Version:
modern, type-safe collection of utility functions
26 lines (24 loc) • 610 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
Object.defineProperty(exports, 'hasKey', {
enumerable: true,
get: function () {
return hasKey;
}
});
//# sourceMappingURL=hasKey-Bt_UpAcG.cjs.map