* 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)
| 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 | |
| 286 | module.exports = WeakTupleMap; |