MCPcopy
hub / github.com/webpack/webpack / _get

Method _get

lib/util/WeakTupleMap.js:242–283  ·  view source on GitHub ↗

* Returns the child node for a tuple element, creating and storing it when * necessary. * @private * @param {ArrayElement<K>} thing thing * @returns {WeakTupleMap<K, V>} value

(thing)

Source from the content-addressed store, hash-verified

240 * @returns {WeakTupleMap<K, V>} value
241 */
242 _get(thing) {
243 if (isWeakKey(thing)) {
244 if ((this.f & 4) !== 4) {
245 /** @type {W<K, V>} */
246 const newMap = new WeakMap();
247 this.f |= 4;
248 /** @type {WeakTupleMap<K, V>} */
249 const newNode = new WeakTupleMap();
250 (this.w = newMap).set(thing, newNode);
251 return newNode;
252 }
253 const entry = /** @type {W<K, V>} */ (this.w).get(thing);
254 if (entry !== undefined) {
255 return entry;
256 }
257 /** @type {WeakTupleMap<K, V>} */
258 const newNode = new WeakTupleMap();
259 /** @type {W<K, V>} */
260 (this.w).set(thing, newNode);
261 return newNode;
262 }
263 if ((this.f & 2) !== 2) {
264 /** @type {M<K, V>} */
265 const newMap = new Map();
266 this.f |= 2;
267 /** @type {WeakTupleMap<K, V>} */
268 const newNode = new WeakTupleMap();
269 (this.m = newMap).set(thing, newNode);
270 return newNode;
271 }
272 const entry =
273 /** @type {M<K, V>} */
274 (this.m).get(thing);
275 if (entry !== undefined) {
276 return entry;
277 }
278 /** @type {WeakTupleMap<K, V>} */
279 const newNode = new WeakTupleMap();
280 /** @type {M<K, V>} */
281 (this.m).set(thing, newNode);
282 return newNode;
283 }
284}
285
286module.exports = WeakTupleMap;

Callers 4

cachedProvideMethod · 0.95
optimizeMethod · 0.80
setMethod · 0.80
provideMethod · 0.80

Calls 3

isWeakKeyFunction · 0.85
setMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected