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

Function load

test/fixtures/es-module-loaders/http-loader.mjs:3–22  ·  view source on GitHub ↗
(url, context, nextLoad)

Source from the content-addressed store, hash-verified

1import { get } from 'http';
2
3export function load(url, context, nextLoad) {
4 if (url.startsWith('http://')) {
5 return new Promise((resolve, reject) => {
6 get(url, (rsp) => {
7 let data = '';
8 rsp.on('data', (chunk) => data += chunk);
9 rsp.on('end', () => {
10 resolve({
11 format: 'module',
12 shortCircuit: true,
13 source: data,
14 });
15 });
16 })
17 .on('error', reject);
18 });
19 }
20
21 return nextLoad(url);
22}

Callers

nothing calls this directly

Calls 3

getFunction · 0.90
resolveFunction · 0.70
onMethod · 0.45

Tested by

no test coverage detected