MCPcopy
hub / github.com/webpack/webpack / add

Method add

lib/util/TupleSet.js:44–66  ·  lib/util/TupleSet.js::TupleSet.add

* Adds a tuple to the set, creating any missing prefix maps along the way. * @param {[T, V, ...EXPECTED_ANY]} args tuple * @returns {void}

(...args)

Source from the content-addressed store, hash-verified

42 * @returns {void}
43 */
44 add(...args) {
45 let map = this._map;
46 for (let i = 0; i < args.length - 2; i++) {
47 const arg = args[i];
48 const innerMap = map.get(arg);
49 if (innerMap === undefined) {
50 map.set(arg, (map = new Map()));
51 } else {
52 map = /** @type {InnerMap<T, V>} */ (innerMap);
53 }
54 }
55
56 const beforeLast = args[args.length - 2];
57 let set = /** @type {Set<V>} */ (map.get(beforeLast));
58 if (set === undefined) {
59 map.set(beforeLast, (set = new Set()));
60 }
61
62 const last = args[args.length - 1];
63 this.size -= set.size;
64 set.add(last);
65 this.size += set.size;
66 }
67
68 /**
69 * Checks whether the exact tuple is already present in the set.

Callers 2

applyMethod · 0.95
constructorMethod · 0.95

Calls 2

getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected