Skip to content

Commit f77775d

Browse files
committed
refactor size
1 parent a61ec92 commit f77775d

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

lib/ContextModule.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -224,11 +224,18 @@ class ContextModule extends Module {
224224
}
225225

226226
size() {
227-
return this.dependencies.map(function(dep) {
228-
return dep.userRequest.length + 5;
229-
}).reduce(function(a, b) {
230-
return a + b;
231-
}, 160);
227+
// base penalty
228+
let count = 160;
229+
230+
// if we dont have dependencies we stop here.
231+
if(!this.dependencies) {
232+
return count;
233+
}
234+
235+
for(let i = 0; i < this.dependencies.length; i++) {
236+
count += 5 + this.dependencies[i].userRequest.length;
237+
}
238+
return count;
232239
}
233240
}
234241

0 commit comments

Comments
 (0)