MCPcopy
hub / github.com/webpack/webpack / cachedSetProperty

Function cachedSetProperty

lib/util/cleverMerge.js:61–87  ·  view source on GitHub ↗
(obj, property, value)

Source from the content-addressed store, hash-verified

59 * @returns {T} new object
60 */
61const cachedSetProperty = (obj, property, value) => {
62 let mapByProperty = setPropertyCache.get(obj);
63
64 if (mapByProperty === undefined) {
65 mapByProperty = new Map();
66 setPropertyCache.set(obj, mapByProperty);
67 }
68
69 let mapByValue = mapByProperty.get(property);
70
71 if (mapByValue === undefined) {
72 mapByValue = new Map();
73 mapByProperty.set(property, mapByValue);
74 }
75
76 let result = mapByValue.get(value);
77
78 if (result) return /** @type {T} */ (result);
79
80 result = {
81 ...obj,
82 [property]: value
83 };
84 mapByValue.set(value, result);
85
86 return /** @type {T} */ (result);
87};
88
89/**
90 * Defines the by values type used by this module.

Callers 4

handleExternalsMethod · 0.85
createMethod · 0.85
defaultResolveMethod · 0.85
applyMethod · 0.85

Calls 2

getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected