MCPcopy
hub / github.com/axios/axios / isPlainObject

Function isPlainObject

lib/utils.js:186–202  ·  view source on GitHub ↗
(val)

Source from the content-addressed store, hash-verified

184 * @returns {boolean} True if value is a plain Object, otherwise false
185 */
186const isPlainObject = (val) => {
187 if (!isObject(val)) {
188 return false;
189 }
190
191 const prototype = getPrototypeOf(val);
192 return (
193 (prototype === null ||
194 prototype === Object.prototype ||
195 getPrototypeOf(prototype) === null) &&
196 // Treat any genuine (non-Object.prototype-polluted) Symbol.toStringTag or
197 // Symbol.iterator as evidence the value is a tagged/iterable type rather
198 // than a plain object, while ignoring keys injected onto Object.prototype.
199 !hasOwnInPrototypeChain(val, toStringTag) &&
200 !hasOwnInPrototypeChain(val, iterator)
201 );
202};
203
204/**
205 * Determine if a value is an empty object (safely handles Buffers)

Callers 1

assignValueFunction · 0.85

Calls 3

isObjectFunction · 0.85
getPrototypeOfFunction · 0.85
hasOwnInPrototypeChainFunction · 0.85

Tested by

no test coverage detected