WXL
3 天以前 3bd962a6d7f61239c020e2dbbeb7341e5b842dd1
node_modules/webpack/lib/util/StackedCacheMap.js
@@ -31,6 +31,10 @@
 * @template V
 */
class StackedCacheMap {
   /**
    * Initializes the mutable fallback map and the stack of immutable cache
    * layers.
    */
   constructor() {
      /** @type {Map<K, V>} */
      this.map = new Map();
@@ -39,9 +43,9 @@
   }
   /**
    * If `immutable` is true, the map can be referenced by the StackedCacheMap
    * and should not be changed afterwards. If the map is mutable, all items
    * are copied into a fallback Map.
    * Adds another cache layer. Immutable maps are retained by reference and
    * reordered so larger layers are checked first, while mutable maps are
    * copied into the fallback map.
    * @param {ReadonlyMap<K, V>} map map to add
    * @param {boolean=} immutable if 'map' is immutable and StackedCacheMap can keep referencing it
    */
@@ -64,6 +68,7 @@
   }
   /**
    * Stores or overrides a value in the mutable fallback map.
    * @param {K} item the key of the element to add
    * @param {V} value the value of the element to add
    * @returns {void}
@@ -73,6 +78,8 @@
   }
   /**
    * Rejects deletions because this data structure is optimized for append-only
    * cache layers.
    * @param {K} item the item to delete
    * @returns {void}
    */
@@ -81,6 +88,8 @@
   }
   /**
    * Rejects `has` checks because they would force the same layered lookup work
    * as `get` without returning the cached value.
    * @param {K} item the item to test
    * @returns {boolean} true if the item exists in this set
    */
@@ -91,6 +100,8 @@
   }
   /**
    * Looks up a key by scanning immutable cache layers first and then the
    * mutable fallback map.
    * @param {K} item the key of the element to return
    * @returns {V | undefined} the value of the element
    */
@@ -102,12 +113,17 @@
      return this.map.get(item);
   }
   /**
    * Removes every cache layer and clears the mutable fallback map.
    */
   clear() {
      this.stack.length = 0;
      this.map.clear();
   }
   /**
    * Returns the total number of entries across the fallback map and all stacked
    * cache layers.
    * @returns {number} size of the map
    */
   get size() {
@@ -119,6 +135,7 @@
   }
   /**
    * Iterates over the fallback map first and then each stacked cache layer.
    * @returns {Iterator<[K, V]>} iterator
    */
   [Symbol.iterator]() {