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

Function transformExpression

packages/plugin-datasource/src/utils.ts:15–28  ·  view source on GitHub ↗
(code: string, context: IDataSourceRuntimeContext)

Source from the content-addressed store, hash-verified

13}
14
15export const transformExpression = (code: string, context: IDataSourceRuntimeContext) => {
16 // 补充异常情况兼容性
17 if (code === undefined) {
18 return () => {}
19 }
20 if (code === '') {
21 return () => ''
22 }
23 try {
24 return new Function(`return (${code})`).call(context)
25 } catch (error) {
26 console.error(`transformExpression error, code is ${code}, context is ${context}, error is ${error}`)
27 }
28}
29
30export const transformFunction = (code: string, context: IDataSourceRuntimeContext) => {
31 if (code === undefined) {

Callers 2

getRuntimeJsValueFunction · 0.85
buildJsonObjFunction · 0.85

Calls 1

errorMethod · 0.45

Tested by

no test coverage detected