* 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)
| 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); |
no outgoing calls
no test coverage detected