mirror of https://github.com/nodejs/node.git
23 lines
496 B
JavaScript
23 lines
496 B
JavaScript
import { get } from 'http';
|
|
|
|
export function load(url, context, nextLoad) {
|
|
if (url.startsWith('http://')) {
|
|
return new Promise((resolve, reject) => {
|
|
get(url, (rsp) => {
|
|
let data = '';
|
|
rsp.on('data', (chunk) => data += chunk);
|
|
rsp.on('end', () => {
|
|
resolve({
|
|
format: 'module',
|
|
shortCircuit: true,
|
|
source: data,
|
|
});
|
|
});
|
|
})
|
|
.on('error', reject);
|
|
});
|
|
}
|
|
|
|
return nextLoad(url);
|
|
}
|