MCPcopy
hub / github.com/alibaba/lowcode-engine / getValue

Function getValue

packages/renderer-core/src/utils/common.ts:111–128  ·  view source on GitHub ↗
(obj: any, path: string, defaultValue = {})

Source from the content-addressed store, hash-verified

109 * @returns string
110 */
111export function getValue(obj: any, path: string, defaultValue = {}) {
112 // array is not valid type, return default value
113 if (Array.isArray(obj)) {
114 return defaultValue;
115 }
116
117 if (isEmpty(obj) || typeof obj !== 'object') {
118 return defaultValue;
119 }
120
121 const res = path.split('.').reduce((pre, cur) => {
122 return pre && pre[cur];
123 }, obj);
124 if (res === undefined) {
125 return defaultValue;
126 }
127 return res;
128}
129
130/**
131 * 用于处理国际化字符串

Callers 5

executeLifeCycleMethodFunction · 0.90
BaseRendererClass · 0.90
common.test.tsFile · 0.90
valueStateMethod · 0.50
getValueMethod · 0.50

Calls 1

reduceMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…