Skip to content

Commit f062f49

Browse files
committed
make clearer what "parents" are
1 parent 3b4eb0f commit f062f49

1 file changed

Lines changed: 23 additions & 23 deletions

File tree

lib/Chunk.js

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ class Chunk {
8484
return this.addToCollection(this.chunks, chunk);
8585
}
8686

87-
addParent(parent) {
88-
return this.addToCollection(this.parents, parent);
87+
addParent(parentChunk) {
88+
return this.addToCollection(this.parents, parentChunk);
8989
}
9090

9191
addModule(module) {
@@ -123,11 +123,11 @@ class Chunk {
123123
});
124124

125125
// cleanup parents
126-
this.parents.forEach(parent => {
126+
this.parents.forEach(parentChunk => {
127127
// remove this chunk from its parents
128-
const idx = parent.chunks.indexOf(this);
128+
const idx = parentChunk.chunks.indexOf(this);
129129
if(idx >= 0) {
130-
parent.chunks.splice(idx, 1);
130+
parentChunk.chunks.splice(idx, 1);
131131
}
132132

133133
// cleanup "sub chunks"
@@ -137,9 +137,9 @@ class Chunk {
137137
* it "sub chunks" and parents directly
138138
*/
139139
// add parent to each "sub chunk"
140-
chunk.addParent(parent);
140+
chunk.addParent(parentChunk);
141141
// add "sub chunk" to parent
142-
parent.addChunk(chunk);
142+
parentChunk.addChunk(chunk);
143143

144144
// remove this as parent of every "sub chunk"
145145
const idx = chunk.parents.indexOf(this);
@@ -179,13 +179,13 @@ class Chunk {
179179
}
180180
}
181181

182-
replaceParent(oldParent, newParent) {
183-
const idx = this.parents.indexOf(oldParent);
182+
replaceParentChunk(oldParentChunk, newParentChunk) {
183+
const idx = this.parents.indexOf(oldParentChunk);
184184
if(idx >= 0) {
185185
this.parents.splice(idx, 1);
186186
}
187-
if(this !== newParent && newParent.addChunk(this)) {
188-
this.addParent(newParent);
187+
if(this !== newParentChunk && newParentChunk.addChunk(this)) {
188+
this.addParent(newParentChunk);
189189
}
190190
}
191191

@@ -198,10 +198,10 @@ class Chunk {
198198
otherChunkModules.forEach(module => otherChunk.moveModule(module, this));
199199
otherChunk.modules.length = 0;
200200

201-
otherChunk.parents.forEach(parent => parent.replaceChunk(otherChunk, this));
201+
otherChunk.parents.forEach(parentChunk => parentChunk.replaceChunk(otherChunk, this));
202202
otherChunk.parents.length = 0;
203203

204-
otherChunk.chunks.forEach(chunk => chunk.replaceParent(otherChunk, this));
204+
otherChunk.chunks.forEach(chunk => chunk.replaceParentChunk(otherChunk, this));
205205
otherChunk.chunks.length = 0;
206206

207207
otherChunk.blocks.forEach(b => {
@@ -226,8 +226,8 @@ class Chunk {
226226
this.chunks = this.chunks.filter(chunk => {
227227
return chunk !== otherChunk && chunk !== this;
228228
});
229-
this.parents = this.parents.filter(parent => {
230-
return parent !== otherChunk && parent !== this;
229+
this.parents = this.parents.filter(parentChunk => {
230+
return parentChunk !== otherChunk && parentChunk !== this;
231231
});
232232
return true;
233233
}
@@ -241,9 +241,9 @@ class Chunk {
241241
newChunk.chunks.push(chunk);
242242
chunk.parents.push(newChunk);
243243
});
244-
this.parents.forEach(parent => {
245-
parent.chunks.push(newChunk);
246-
newChunk.parents.push(parent);
244+
this.parents.forEach(parentChunk => {
245+
parentChunk.chunks.push(newChunk);
246+
newChunk.parents.push(parentChunk);
247247
});
248248
this.entrypoints.forEach(entrypoint => {
249249
entrypoint.insertChunk(newChunk, this);
@@ -351,11 +351,11 @@ class Chunk {
351351
if(child.parents.indexOf(chunk) < 0)
352352
throw new Error(`checkConstraints: child missing parent ${chunk.debugId} -> ${child.debugId}`);
353353
});
354-
chunk.parents.forEach((parent, idx) => {
355-
if(chunk.parents.indexOf(parent) !== idx)
356-
throw new Error(`checkConstraints: duplicate parent in chunk ${chunk.debugId} ${parent.debugId}`);
357-
if(parent.chunks.indexOf(chunk) < 0)
358-
throw new Error(`checkConstraints: parent missing child ${parent.debugId} <- ${chunk.debugId}`);
354+
chunk.parents.forEach((parentChunk, idx) => {
355+
if(chunk.parents.indexOf(parentChunk) !== idx)
356+
throw new Error(`checkConstraints: duplicate parent in chunk ${chunk.debugId} ${parentChunk.debugId}`);
357+
if(parentChunk.chunks.indexOf(chunk) < 0)
358+
throw new Error(`checkConstraints: parent missing child ${parentChunk.debugId} <- ${chunk.debugId}`);
359359
});
360360
}
361361
}

0 commit comments

Comments
 (0)