MCPcopy Create free account
hub / github.com/zxlie/FeHelper / createNativeFunction

Function createNativeFunction

test/dynamic-runtime.test.js:23–35  ·  view source on GitHub ↗
(context = {})

Source from the content-addressed store, hash-verified

21
22describe('dynamic runtime developer support', () => {
23 function createNativeFunction(context = {}) {
24 return function (...args) {
25 const code = String(args.pop() || '');
26 const names = args;
27 return function (...values) {
28 const sandbox = { console, ...context };
29 names.forEach((name, index) => {
30 sandbox[name] = values[index];
31 });
32 return vm.runInNewContext(`(function(){${code}\n}).call(this)`, sandbox);
33 };
34 };
35 }
36
37 it('dynamic index.html uses external helper scripts instead of inline bootstrap', () => {
38 const html = fs.readFileSync(path.resolve('apps/dynamic/index.html'), 'utf8');

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected