MCPcopy Index your code
hub / github.com/nodejs/node / simple

Function simple

test/parallel/test-vm-module-link.js:11–29  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

9const { SourceTextModule } = require('vm');
10
11async function simple() {
12 const foo = new SourceTextModule('export default 5;');
13 await foo.link(common.mustNotCall());
14
15 globalThis.fiveResult = undefined;
16 const bar = new SourceTextModule('import five from "foo"; fiveResult = five');
17
18 assert.deepStrictEqual(bar.dependencySpecifiers, ['foo']);
19
20 await bar.link(common.mustCall((specifier, module) => {
21 assert.strictEqual(module, bar);
22 assert.strictEqual(specifier, 'foo');
23 return foo;
24 }));
25
26 await bar.evaluate();
27 assert.strictEqual(globalThis.fiveResult, 5);
28 delete globalThis.fiveResult;
29}
30
31async function invalidLinkValue() {
32 const invalidValues = [

Callers 1

Calls 2

linkMethod · 0.45
evaluateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…