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

Function load

test/fixtures/module-hooks/add-hook.js:9–21  ·  view source on GitHub ↗
(url, context, nextLoad)

Source from the content-addressed store, hash-verified

7// hooks.
8function addHook(hook, options) {
9 function load(url, context, nextLoad) {
10 const result = nextLoad(url, context);
11 const index = url.lastIndexOf('.');
12 const ext = url.slice(index);
13 if (!options.exts.includes(ext)) {
14 return result;
15 }
16 const filename = fileURLToPath(url);
17 if (!options.matcher(filename)) {
18 return result;
19 }
20 return { ...result, source: hook(result.source.toString(), filename) }
21 }
22
23 const registered = registerHooks({ load });
24

Callers

nothing calls this directly

Calls 5

fileURLToPathFunction · 0.85
includesMethod · 0.80
sliceMethod · 0.65
hookFunction · 0.50
toStringMethod · 0.45

Tested by

no test coverage detected