MCPcopy
hub / github.com/axios/axios / hasOwnInPrototypeChain

Function hasOwnInPrototypeChain

lib/utils.js:30–46  ·  view source on GitHub ↗
(thing, prop)

Source from the content-addressed store, hash-verified

28 * @returns {boolean} True when `prop` is owned below Object.prototype
29 */
30const hasOwnInPrototypeChain = (thing, prop) => {
31 let obj = thing;
32 const seen = [];
33
34 while (obj != null && obj !== Object.prototype) {
35 if (seen.indexOf(obj) !== -1) {
36 return false;
37 }
38 seen.push(obj);
39
40 if (hasOwnProperty(obj, prop)) {
41 return true;
42 }
43 obj = getPrototypeOf(obj);
44 }
45 return false;
46};
47
48/**
49 * Read `obj[prop]` only when it is safe from Object.prototype pollution. Own

Callers 3

getSafePropFunction · 0.85
isPlainObjectFunction · 0.85
isSafeIterableFunction · 0.85

Calls 1

getPrototypeOfFunction · 0.85

Tested by

no test coverage detected