MCPcopy Create free account
hub / github.com/Easy-Editor/EasyEditor / parseData

Function parseData

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

Source from the content-addressed store, hash-verified

91}
92
93export const parseData = (schema: unknown, self: any, options: IParseOptions = {}): any => {
94 if (isJSExpression(schema)) {
95 return parseExpression({
96 str: schema,
97 self,
98 thisRequired: true,
99 logScope: options.logScope,
100 })
101 }
102 if (typeof schema === 'string') {
103 return schema.trim()
104 } else if (Array.isArray(schema)) {
105 return schema.map(item => parseData(item, self, options))
106 } else if (typeof schema === 'function') {
107 return schema.bind(self)
108 } else if (typeof schema === 'object') {
109 // 对于undefined及null直接返回
110 if (!schema) {
111 return schema
112 }
113 const res: any = {}
114 Object.entries(schema).forEach(([key, val]) => {
115 if (key.startsWith('__')) {
116 return
117 }
118 res[key] = parseData(val, self, options)
119 })
120 return res
121 }
122 return schema
123}
124
125export const isUseLoop = (loop: null | any[], isDesignMode: boolean): boolean => {
126 if (!isDesignMode) {

Callers 1

BaseRendererClass · 0.90

Calls 5

isJSExpressionFunction · 0.90
parseExpressionFunction · 0.85
bindMethod · 0.65
mapMethod · 0.45
forEachMethod · 0.45

Tested by

no test coverage detected