(schema: unknown, self: any, options: IParseOptions = {})
| 91 | } |
| 92 | |
| 93 | export 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 | |
| 125 | export const isUseLoop = (loop: null | any[], isDesignMode: boolean): boolean => { |
| 126 | if (!isDesignMode) { |
no test coverage detected