MCPcopy
hub / github.com/webpack/webpack / getFromCache

Method getFromCache

lib/util/SortableSet.js:115–128  ·  view source on GitHub ↗

* Get data from cache * @template R * @param {(set: SortableSet<T>) => R} fn function to calculate value * @returns {R} returns result of fn(this), cached until set changes

(fn)

Source from the content-addressed store, hash-verified

113 * @returns {R} returns result of fn(this), cached until set changes
114 */
115 getFromCache(fn) {
116 if (this._cache === undefined) {
117 this._cache = new Map();
118 } else {
119 const result = this._cache.get(fn);
120 const data = /** @type {R} */ (result);
121 if (data !== undefined) {
122 return data;
123 }
124 }
125 const newData = fn(this);
126 this._cache.set(fn, newData);
127 return newData;
128 }
129
130 /**
131 * Get data from cache (ignoring sorting)

Callers 4

getChildrenMethod · 0.80
getParentsMethod · 0.80
getBlocksMethod · 0.80
getModuleChunksMethod · 0.80

Calls 3

fnFunction · 0.70
getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected