MCPcopy
hub / github.com/webpack/webpack / get

Method get

lib/Cache.js:93–117  ·  lib/Cache.js::Cache.get

* Retrieves a cached value and lets registered `gotHandlers` observe the * result before the caller receives it. * @template T * @param {string} identifier the cache identifier * @param {Etag | null} etag the etag * @param {CallbackCache<T>} callback signals when the value is retrieved *

(identifier, etag, callback)

Source from the content-addressed store, hash-verified

91 * @returns {void}
92 */
93 get(identifier, etag, callback) {
94 /** @type {GotHandler<T>[]} */
95 const gotHandlers = [];
96 this.hooks.get.callAsync(identifier, etag, gotHandlers, (err, result) => {
97 if (err) {
98 callback(makeWebpackError(err, class="st">"Cache.hooks.get"));
99 return;
100 }
101 if (result === null) {
102 result = undefined;
103 }
104 if (gotHandlers.length > 1) {
105 const innerCallback = needCalls(gotHandlers.length, () =>
106 callback(null, result)
107 );
108 for (const gotHandler of gotHandlers) {
109 gotHandler(result, innerCallback);
110 }
111 } else if (gotHandlers.length === 1) {
112 gotHandlers[0](result, () => callback(null, result));
113 } else {
114 callback(null, result);
115 }
116 });
117 }
118
119 /**
120 * Stores a cache entry for the identifier and etag through the registered

Callers 15

versionMethod · 0.45
applyMethod · 0.45
handlerMethod · 0.45
addValueDependencyMethod · 0.45
applyDefineKeyMethod · 0.45
addToMapMethod · 0.45
getConnectionsByKeyFunction · 0.45
_getModuleGraphModuleMethod · 0.45
getConnectionMethod · 0.45
getMetaMethod · 0.45

Calls 3

makeWebpackErrorFunction · 0.85
needCallsFunction · 0.70
callbackFunction · 0.50

Tested by

no test coverage detected