MCPcopy
hub / github.com/jestjs/jest / hasPropertyInObject

Function hasPropertyInObject

packages/expect-utils/src/utils.ts:32–44  ·  view source on GitHub ↗
(object: object, key: string | symbol)

Source from the content-addressed store, hash-verified

30 * Checks if `hasOwnProperty(object, key)` up the prototype chain, stopping at `Object.prototype`.
31 */
32const hasPropertyInObject = (object: object, key: string | symbol): boolean => {
33 const shouldTerminate =
34 !object || typeof object !== 'object' || object === Object.prototype;
35
36 if (shouldTerminate) {
37 return false;
38 }
39
40 return (
41 Object.prototype.hasOwnProperty.call(object, key) ||
42 hasPropertyInObject(Object.getPrototypeOf(object), key)
43 );
44};
45
46// Retrieves an object's keys for evaluation by getObjectSubset. This evaluates
47// the prototype chain for string keys but not for non-enumerable symbols.

Callers 2

getObjectSubsetFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected