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

Function getFormatOfExtensionlessFile

lib/internal/modules/esm/get_format.js:60–68  ·  view source on GitHub ↗

* For extensionless files in a `module` package scope, we check the file contents to disambiguate between ES module * JavaScript and Wasm. * We do this by taking advantage of the fact that all Wasm files start with the header `0x00 0x61 0x73 0x6d` (`_asm`). * @param {URL} url * @returns {'wasm'|

(url)

Source from the content-addressed store, hash-verified

58 * @returns {'wasm'|'module'}
59 */
60function getFormatOfExtensionlessFile(url) {
61 const path = getValidatedPath(url);
62 switch (fsBindings.getFormatOfExtensionlessFile(path)) {
63 case internalConstants.EXTENSIONLESS_FORMAT_WASM:
64 return 'wasm';
65 default:
66 return 'module';
67 }
68}
69const { containsModuleSyntax } = internalBinding('contextify');
70const { getPackageScopeConfig, getPackageType } = require('internal/modules/package_json_reader');
71const { fileURLToPath } = require('internal/url');

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…