@@ -35,15 +35,17 @@ const kUserFunctionCacheSize = 2
3535// Maximum nesting of JS user function calls (not the JS stack depth)
3636var kUserFunctionMaxCallDepth = 20
3737
38- // The outermost JavaScript code. Evaluating it returns a function, which is then called by the
39- // Runner every time it's invoked. Contains `%s` where the actual function source code goes .
38+ // kJavaScriptWrapperFormatString is the format string containing the outermost JavaScript code.
39+ // Evaluating it returns a function, which is then called by the runner every time it's invoked .
4040//
41- //go:embed js_wrapper.js
42- var kJavaScriptWrapper string
41+ // Contains `%s` where the actual function source code goes.
42+ //
43+ //go:embed js_wrapper.fmt.js
44+ var kJavaScriptWrapperFormatString string
4345
4446// Creates a JSServer instance wrapping a userJSRunner, for user JS functions.
4547func newFunctionJSServer (ctx context.Context , name string , what string , sourceCode string ) (* sgbucket.JSServer , error ) {
46- js := fmt .Sprintf (kJavaScriptWrapper , sourceCode )
48+ js := fmt .Sprintf (kJavaScriptWrapperFormatString , sourceCode )
4749 jsServer := sgbucket .NewJSServer (ctx , js , 0 , kUserFunctionCacheSize ,
4850 func (ctx context.Context , fnSource string , timeout time.Duration ) (sgbucket.JSServerTask , error ) {
4951 return newJSRunner (ctx , name , what , fnSource )
0 commit comments