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