MCPcopy Create free account
hub / github.com/nodejs/node / load

Function load

test/fixtures/es-module-loaders/mock-loader.mjs:87–102  ·  view source on GitHub ↗
(url, context, defaultLoad)

Source from the content-addressed store, hash-verified

85}
86
87export async function load(url, context, defaultLoad) {
88 doDrainPort();
89 /**
90 * Mocked fake module, not going to be handled in default way so it
91 * generates the source text, then short circuits
92 */
93 if (url.startsWith('mock-facade:')) {
94 const encodedTargetURL = url.slice(url.lastIndexOf(':') + 1);
95 return {
96 shortCircuit: true,
97 source: generateModule(encodedTargetURL),
98 format: 'module',
99 };
100 }
101 return defaultLoad(url, context);
102}
103
104/**
105 * Generate the source code for a mocked module.

Callers

nothing calls this directly

Calls 4

doDrainPortFunction · 0.85
generateModuleFunction · 0.85
defaultLoadFunction · 0.85
sliceMethod · 0.65

Tested by

no test coverage detected