| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 6390f70 commit b6760b3
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -26,32 +26,7 @@ const { | |||
| 26 | 26 | ||
| 27 | 27 | /** | |
| 28 | 28 | * @param {URL} url URL to the module | |
| 29 | - * @param {ESModuleContext} context used to decorate error messages | ||
| 30 | - * @returns {Promise<{ responseURL: string, source: string | BufferView }>} | ||
| 31 | - */ | ||
| 32 | - async function getSource(url, context) { | ||
| 33 | - const { protocol, href } = url; | ||
| 34 | - const responseURL = href; | ||
| 35 | - let source; | ||
| 36 | - if (protocol === 'file:') { | ||
| 37 | - const { readFile: readFileAsync } = require('internal/fs/promises').exports; | ||
| 38 | - source = await readFileAsync(url); | ||
| 39 | - } else if (protocol === 'data:') { | ||
| 40 | - const result = dataURLProcessor(url); | ||
| 41 | - if (result === 'failure') { | ||
| 42 | - throw new ERR_INVALID_URL(responseURL, null); | ||
| 43 | - } | ||
| 44 | - source = BufferFrom(result.body); | ||
| 45 | - } else { | ||
| 46 | - const supportedSchemes = ['file', 'data']; | ||
| 47 | - throw new ERR_UNSUPPORTED_ESM_URL_SCHEME(url, supportedSchemes); | ||
| 48 | - } | ||
| 49 | - return { __proto__: null, responseURL, source }; | ||
| 50 | - } | ||
| 51 | - | ||
| 52 | - /** | ||
| 53 | - * @param {URL} url URL to the module | ||
| 54 | - * @param {ESModuleContext} context used to decorate error messages | ||
| 29 | + * @param {LoadContext} context used to decorate error messages | ||
| 55 | 30 | * @returns {{ responseURL: string, source: string | BufferView }} | |
| 56 | 31 | */ | |
| 57 | 32 | function getSourceSync(url, context) { | |
@@ -80,7 +55,7 @@ function getSourceSync(url, context) { | |||
| 80 | 55 | * @param {LoadContext} context | |
| 81 | 56 | * @returns {LoadReturn} | |
| 82 | 57 | */ | |
| 83 | - async function defaultLoad(url, context = kEmptyObject) { | ||
| 58 | + function defaultLoad(url, context = kEmptyObject) { | ||
| 84 | 59 | let responseURL = url; | |
| 85 | 60 | let { | |
| 86 | 61 | importAttributes, | |
@@ -110,13 +85,13 @@ async function defaultLoad(url, context = kEmptyObject) { | |||
| 110 | 85 | source = null; | |
| 111 | 86 | } else if (format !== 'commonjs') { | |
| 112 | 87 | if (source == null) { | |
| 113 | - ({ responseURL, source } = await getSource(urlInstance, context)); | ||
| 88 | + ({ responseURL, source } = getSourceSync(urlInstance, context)); | ||
| 114 | 89 | context = { __proto__: context, source }; | |
| 115 | 90 | } | |
| 116 | 91 | ||
| 117 | 92 | if (format == null) { | |
| 118 | 93 | // Now that we have the source for the module, run `defaultGetFormat` to detect its format. | |
| 119 | - format = await defaultGetFormat(urlInstance, context); | ||
| 94 | + format = defaultGetFormat(urlInstance, context); | ||
| 120 | 95 | ||
| 121 | 96 | if (format === 'commonjs') { | |
| 122 | 97 | // For backward compatibility reasons, we need to discard the source in | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -806,9 +806,9 @@ class ModuleLoader { | |||
| 806 | 806 | * if any. | |
| 807 | 807 | * @param {string} url The URL of the module to be loaded. | |
| 808 | 808 | * @param {object} context Metadata about the module | |
| 809 | - * @returns {Promise<{ format: ModuleFormat, source: ModuleSource }>} | ||
| 809 | + * @returns {Promise<{ format: ModuleFormat, source: ModuleSource }> | { format: ModuleFormat, source: ModuleSource }} | ||
| 810 | 810 | */ | |
| 811 | - async load(url, context) { | ||
| 811 | + load(url, context) { | ||
| 812 | 812 | if (loadHooks.length) { | |
| 813 | 813 | // Has module.registerHooks() hooks, use the synchronous variant that can handle both hooks. | |
| 814 | 814 | return this.#loadSync(url, context); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -264,7 +264,7 @@ function normalizeReferrerURL(referrerName) { | |||
| 264 | 264 | } | |
| 265 | 265 | ||
| 266 | 266 | if (StringPrototypeStartsWith(referrerName, 'file://') || | |
| 267 | - URLCanParse(referrerName)) { | ||
| 267 | + URLCanParse(referrerName)) { | ||
| 268 | 268 | return referrerName; | |
| 269 | 269 | } | |
| 270 | 270 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments