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

Function transformFunction

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

Source from the content-addressed store, hash-verified

28}
29
30export const transformFunction = (code: string, context: IDataSourceRuntimeContext) => {
31 if (code === undefined) {
32 return () => {}
33 }
34 if (code === '') {
35 return () => ''
36 }
37 try {
38 return new Function(`return (${code})`).call(context).bind(context)
39 } catch (error) {
40 console.error(`transformFunction error, code is ${code}, context is ${context}, error is ${error}`)
41 }
42}
43
44export const transformBoolStr = (str: string) => {
45 return str !== 'false'

Callers 1

getRuntimeJsValueFunction · 0.85

Calls 2

bindMethod · 0.65
errorMethod · 0.45

Tested by

no test coverage detected