You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This method creates a function out of a string and returns it. The returned function executes the string as code in a sandbox. The string can be any valid javascript code.
33
+
This method creates a function out of a string and returns it. The returned function executes the string as code in the passed sandbox object. The string can be any valid javascript code and it is
34
+
always executed in strict mode.
33
35
34
36
```js
35
37
constcode=compiler.compileCode('const sum = prop1 + prop2')
36
38
```
37
39
38
-
### compiler.compileExpression(String)
40
+
### compiler.compileExpression(String, Object)
39
41
40
-
This method creates a function out of a string and returns it. The returned function executes the string as an expression in a sandbox and returns the result of this execution. The string can be any javascript code that may follow a return statement.
42
+
This method creates a function out of a string and returns it. The returned function executes the string as an expression in the passed sandbox object and returns the result of this execution. The string can be any javascript code that may follow a return statement and it is always executed in
### using the returned function, expression(Object, [Array | true])
49
+
### compiler.secure(String, ..., String)
47
50
48
-
Pass an object as the first argument, this will be the sandbox the function executes in. Optionally you can expose global variables by passing an Array of variable names as second argument. Passing true as the second argument exposes every global variable.
51
+
This methods secures the sandbox and the compiled code. It prevents access to the global scope
52
+
from inside the passed code. You can optionally pass global variable names as strings to expose
53
+
them to the sandbox. Exposed global variables and the prototypes of literals (strings, numbers, etc.)
54
+
are deep frozen with Object.freeze() to prevent security leaks. Deep frozen means that their whole prototype chain and all constructors found on that prototype chain are frozen. Calling secure more than once throws an error.
0 commit comments