|
2 | 2 | MIT License http://www.opensource.org/licenses/mit-license.php |
3 | 3 | Author Tobias Koppers @sokra |
4 | 4 | */ |
5 | | -function Entrypoint(name) { |
6 | | - this.name = name; |
7 | | - this.chunks = []; |
8 | | -} |
9 | | -module.exports = Entrypoint; |
| 5 | +"use strict"; |
10 | 6 |
|
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 | + } |
15 | 17 |
|
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); |
22 | 26 | } |
23 | | - chunk.entrypoints.push(this); |
24 | | -}; |
25 | 27 |
|
26 | | -Entrypoint.prototype.getFiles = function() { |
27 | | - var files = []; |
| 28 | + getFiles() { |
| 29 | + let files = []; |
28 | 30 |
|
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 | + } |
33 | 36 | } |
34 | 37 | } |
35 | | - } |
36 | 38 |
|
37 | | - return files; |
| 39 | + return files; |
| 40 | + } |
38 | 41 | } |
| 42 | + |
| 43 | +module.exports = Entrypoint; |
0 commit comments