MCPcopy
hub / github.com/baidu/amis / createObject

Function createObject

packages/amis-core/src/utils/object.ts:6–31  ·  view source on GitHub ↗
(
  superProps?: P,
  props?: P,
  properties?: any
)

Source from the content-addressed store, hash-verified

4
5// 方便取值的时候能够把上层的取到,但是获取的时候不会全部把所有的数据获取到。
6export function createObject<P extends {[propName: string]: any} | null>(
7 superProps?: P,
8 props?: P,
9 properties?: any
10): object {
11 if (superProps && Object.isFrozen(superProps)) {
12 superProps = cloneObject(superProps);
13 }
14
15 const obj = superProps
16 ? Object.create(superProps, {
17 ...properties,
18 __super: {
19 value: superProps,
20 writable: false,
21 enumerable: false
22 }
23 })
24 : Object.create(Object.prototype, properties);
25
26 props &&
27 isObject(props) &&
28 Object.keys(props).forEach(key => (obj[key] = props[key]));
29
30 return obj;
31}
32
33export function extractObjectChain(value: any) {
34 const result: Array<object> = value ? [value] : [];

Callers 15

handleActionMethod · 0.90
normalizeNavigationsMethod · 0.90
Nav.tsxFile · 0.90
afterDeferLoadFunction · 0.90
componentDidUpdateMethod · 0.90
toggleLinkMethod · 0.90
saveOrderMethod · 0.90
handleChangeMethod · 0.90
handleSelectMethod · 0.90
reloadMethod · 0.90
handleClickMethod · 0.90
getDataMethod · 0.90

Calls 4

forEachMethod · 0.80
keysMethod · 0.80
cloneObjectFunction · 0.70
isObjectFunction · 0.70

Tested by

no test coverage detected