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

Function parseData

packages/renderer-core/src/utils/common.ts:319–350  ·  view source on GitHub ↗
(schema: unknown, self: any, options: IParseOptions = {})

Source from the content-addressed store, hash-verified

317}
318
319export function parseData(schema: unknown, self: any, options: IParseOptions = {}): any {
320 if (isJSExpression(schema)) {
321 return parseExpression({
322 str: schema,
323 self,
324 thisRequired: options.thisRequiredInJSE,
325 logScope: options.logScope,
326 });
327 } else if (isI18nData(schema)) {
328 return parseI18n(schema, self);
329 } else if (typeof schema === 'string') {
330 return schema.trim();
331 } else if (Array.isArray(schema)) {
332 return schema.map((item) => parseData(item, self, options));
333 } else if (typeof schema === 'function') {
334 return schema.bind(self);
335 } else if (typeof schema === 'object') {
336 // 对于undefined及null直接返回
337 if (!schema) {
338 return schema;
339 }
340 const res: any = {};
341 forEach(schema, (val: any, key: string) => {
342 if (key.startsWith('__')) {
343 return;
344 }
345 res[key] = parseData(val, self, options);
346 });
347 return res;
348 }
349 return schema;
350}
351
352/**
353 * process params for using in a url query

Callers 4

BaseRendererClass · 0.90
mockParserFunction · 0.90
common.test.tsFile · 0.90
__parseDataFunction · 0.90

Calls 7

parseI18nFunction · 0.85
forEachFunction · 0.85
parseExpressionFunction · 0.70
mapMethod · 0.65
bindMethod · 0.65
isJSExpressionFunction · 0.50
isI18nDataFunction · 0.50

Tested by 2

mockParserFunction · 0.72
__parseDataFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…