MCPcopy Create free account
hub / github.com/Paciolan/remote-module-loader / define

Function define

src/lib/loadRemoteModule.ts:58–78  ·  view source on GitHub ↗
(...args: any[])

Source from the content-addressed store, hash-verified

56 }
57
58 const define: any = (...args: any[]) => {
59 let factory: Function;
60 let deps: string[];
61
62 if (typeof args[args.length - 1] === "function") {
63 factory = args.pop();
64 } else {
65 module.exports = args[args.length - 1];
66 return;
67 }
68
69 deps = Array.isArray(args[args.length - 1]) ? args.pop() : ["require", "exports", "module"];
70
71 const builtins: Record<string, any> = { exports, require: _requires, module };
72 const resolved = deps.map(dep => builtins[dep] || _requires(dep));
73
74 const result = factory(...resolved);
75 if (result !== undefined) {
76 module.exports = result;
77 }
78 };
79 define.amd = {};
80
81 const func = new Function("require", "module", "exports", "define", data);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected