mirror of
https://github.com/leporello-js/leporello-js
synced 2026-01-13 13:04:30 -08:00
fix globals
This commit is contained in:
25
src/eval.js
25
src/eval.js
@@ -434,19 +434,18 @@ account
|
|||||||
|
|
||||||
// Workaround with statement forbidden in strict mode (imposed by ES6 modules)
|
// Workaround with statement forbidden in strict mode (imposed by ES6 modules)
|
||||||
// Also currently try/catch is not implemented TODO
|
// Also currently try/catch is not implemented TODO
|
||||||
|
export const eval_codestring = (codestring, scope) =>
|
||||||
|
// Note that we eval code in context of run_window
|
||||||
// TODO also create in Iframe Context?
|
(new (globalThis.run_window.Function)('codestring', 'scope',
|
||||||
const eval_codestring = new Function('codestring', 'scope',
|
// Make a copy of `scope` to not mutate it with assignments
|
||||||
// Make a copy of `scope` to not mutate it with assignments
|
`
|
||||||
`
|
try {
|
||||||
try {
|
return {ok: true, value: eval('with({...scope}){' + codestring + '}')}
|
||||||
return {ok: true, value: eval('with({...scope}){' + codestring + '}')}
|
} catch(error) {
|
||||||
} catch(error) {
|
return {ok: false, error}
|
||||||
return {ok: false, error}
|
}
|
||||||
}
|
`
|
||||||
`
|
))(codestring, scope)
|
||||||
)
|
|
||||||
|
|
||||||
const get_args_scope = (fn_node, args) => {
|
const get_args_scope = (fn_node, args) => {
|
||||||
const arg_names =
|
const arg_names =
|
||||||
|
|||||||
Reference in New Issue
Block a user