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

Method serializeKey

lib/internal/modules/esm/module_map.js:34–50  ·  view source on GitHub ↗

* Generates the internal serialized cache key and returns it along the actual cache object. * * It is exposed to allow more efficient read and overwrite a cache entry. * @param {string} specifier * @param {Record } importAttributes * @returns {string}

(specifier, importAttributes)

Source from the content-addressed store, hash-verified

32 * @returns {string}
33 */
34 serializeKey(specifier, importAttributes) {
35 // To serialize the ModuleRequest (specifier + list of import attributes),
36 // we need to sort the attributes by key, then stringifying,
37 // so that different import statements with the same attributes are always treated
38 // as identical.
39 const keys = ObjectKeys(importAttributes);
40
41 if (keys.length === 0) {
42 return specifier + '::';
43 }
44
45 return specifier + '::' + ArrayPrototypeJoin(
46 ArrayPrototypeMap(
47 ArrayPrototypeSort(keys),
48 (key) => JSONStringify(key) + JSONStringify(importAttributes[key])),
49 ',');
50 }
51
52 #getModuleCachedImports(parentURL) {
53 let internalCache = super.get(parentURL);

Callers 2

#cachedDefaultResolveMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected