MCPcopy
hub / github.com/didi/mpx / isPlainObject

Function isPlainObject

packages/utils/src/object.js:11–30  ·  view source on GitHub ↗
(value)

Source from the content-addressed store, hash-verified

9}
10
11function isPlainObject (value) {
12 if (value === null || typeof value !== 'object' || type(value) !== 'Object') return false
13 const proto = Object.getPrototypeOf(value)
14 if (proto === null) return true
15 // 处理支付宝接口返回数据对象的__proto__与js中创建对象的__proto__不一致的问题,判断value.__proto__.__proto__ === null时也认为是plainObject
16 const innerProto = Object.getPrototypeOf(proto)
17 if (proto === Object.prototype || innerProto === null) return true
18 // issue #644
19 const observeClassInstance = mpxGlobal.__mpx?.config.observeClassInstance
20 if (observeClassInstance) {
21 if (Array.isArray(observeClassInstance)) {
22 for (let i = 0; i < observeClassInstance.length; i++) {
23 if (proto === observeClassInstance[i].prototype) return true
24 }
25 } else {
26 return true
27 }
28 }
29 return false
30}
31
32function diffAndCloneA (a, b) {
33 let diffData = null

Callers 7

mergeReactiveObjectsFunction · 0.90
forceUpdateMethod · 0.90
createComposerFunction · 0.90
observeFunction · 0.90
traverseFunction · 0.90
toRefsFunction · 0.90
deepDiffAndCloneAFunction · 0.85

Calls 1

typeFunction · 0.90

Tested by

no test coverage detected