Re:A horrifying globalThis polyfill in JavaScript
by bfred_it on Monday May 13, 2019 @03:00AM
(#19896887)
eval doesn’t work with some CSP settings, the article mentions this and other limits of previous solutions.
Re:A horrifying globalThis polyfill in JavaScript
by codedokode on Monday May 13, 2019 @08:44AM
(#19898673)
You use "global_env" only inside luaopen_js(). Why don't you just add it as an argument, for example:
function luaopen_js(L, global) { ... }
instead of writing this ugly hack?
Re:A horrifying globalThis polyfill in JavaScript
by daurnimator on Monday May 13, 2019 @08:00PM
(#19905344)
`luaopen_js` is the entry point for the library with a set API. (that follows https://www.lua.org/manual/5.3/manual.html#lua_CFunction ). The caller cannot pass more arguments.
Re:A horrifying globalThis polyfill in JavaScript
by Technetium_Hat on Monday May 13, 2019 @11:13AM
(#19900059)
Why the comma operator with the eval?
Re:A horrifying globalThis polyfill in JavaScript
by daurnimator on Monday May 13, 2019 @08:03PM
(#19905374)
Have a look at https://stackoverflow.com/a/46397327/282536
In fengari we currently use https://github.com/fengari-lua/fengari-interop/blob/8e59efb7...
I created https://github.com/fengari-lua/fengari-interop/issues/45 to track.