(obj, property, value)
| 59 | * @returns {T} new object |
| 60 | */ |
| 61 | const 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. |
no test coverage detected