Skip to content

Commit 083b9a7

Browse files
committed
refactor(es6): Upgrade Entrypoint to es6
1 parent 79791a5 commit 083b9a7

1 file changed

Lines changed: 30 additions & 25 deletions

File tree

lib/Entrypoint.js

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,42 @@
22
MIT License http://www.opensource.org/licenses/mit-license.php
33
Author Tobias Koppers @sokra
44
*/
5-
function Entrypoint(name) {
6-
this.name = name;
7-
this.chunks = [];
8-
}
9-
module.exports = Entrypoint;
5+
"use strict";
106

11-
Entrypoint.prototype.unshiftChunk = function(chunk) {
12-
this.chunks.unshift(chunk);
13-
chunk.entrypoints.push(this);
14-
};
7+
class Entrypoint {
8+
constructor(name) {
9+
this.name = name;
10+
this.chunks = [];
11+
}
12+
13+
unshiftChunk(chunk) {
14+
this.chunks.unshift(chunk);
15+
chunk.entrypoints.push(this);
16+
}
1517

16-
Entrypoint.prototype.insertChunk = function(chunk, before) {
17-
var idx = this.chunks.indexOf(before);
18-
if(idx >= 0) {
19-
this.chunks.splice(idx, 0, chunk);
20-
} else {
21-
throw new Error("before chunk not found");
18+
insertChunk(chunk, before) {
19+
const idx = this.chunks.indexOf(before);
20+
if(idx >= 0) {
21+
this.chunks.splice(idx, 0, chunk);
22+
} else {
23+
throw new Error("before chunk not found");
24+
}
25+
chunk.entrypoints.push(this);
2226
}
23-
chunk.entrypoints.push(this);
24-
};
2527

26-
Entrypoint.prototype.getFiles = function() {
27-
var files = [];
28+
getFiles() {
29+
let files = [];
2830

29-
for(var chunkIdx = 0; chunkIdx < this.chunks.length; chunkIdx++) {
30-
for(var fileIdx = 0; fileIdx < this.chunks[chunkIdx].files.length; fileIdx++) {
31-
if(files.indexOf(this.chunks[chunkIdx].files[fileIdx]) === -1) {
32-
files.push(this.chunks[chunkIdx].files[fileIdx]);
31+
for(let chunkIdx = 0; chunkIdx < this.chunks.length; chunkIdx++) {
32+
for(let fileIdx = 0; fileIdx < this.chunks[chunkIdx].files.length; fileIdx++) {
33+
if(files.indexOf(this.chunks[chunkIdx].files[fileIdx]) === -1) {
34+
files.push(this.chunks[chunkIdx].files[fileIdx]);
35+
}
3336
}
3437
}
35-
}
3638

37-
return files;
39+
return files;
40+
}
3841
}
42+
43+
module.exports = Entrypoint;

0 commit comments

Comments
 (0)