Skip to content

Commit 1a16a3e

Browse files
committed
make sort function private
1 parent bd8c6cf commit 1a16a3e

2 files changed

Lines changed: 29 additions & 29 deletions

File tree

lib/Chunk.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,26 @@ const compareLocations = require("./compareLocations");
99
const SortableSet = require("./util/SortableSet");
1010
let debugId = 1000;
1111

12-
class Chunk {
13-
14-
static sortById(a, b) {
15-
if(a.id < b.id) return -1;
16-
if(b.id < a.id) return 1;
17-
return 0;
18-
}
12+
const sortById = (a, b) => {
13+
if(a.id < b.id) return -1;
14+
if(b.id < a.id) return 1;
15+
return 0;
16+
};
17+
18+
const sortByIdentifier = (a, b) => {
19+
if(a.identifier() > b.identifier()) return 1;
20+
if(a.identifier() < b.identifier()) return -1;
21+
return 0;
22+
};
1923

20-
static sortByIdentifier(a, b) {
21-
if(a.identifier() > b.identifier()) return 1;
22-
if(a.identifier() < b.identifier()) return -1;
23-
return 0;
24-
}
24+
class Chunk {
2525

2626
constructor(name, module, loc) {
2727
this.id = null;
2828
this.ids = null;
2929
this.debugId = debugId++;
3030
this.name = name;
31-
this._modules = new SortableSet(undefined, Chunk.sortByIdentifier);
31+
this._modules = new SortableSet(undefined, sortByIdentifier);
3232
this.entrypoints = [];
3333
this.chunks = [];
3434
this.parents = [];
@@ -144,7 +144,7 @@ class Chunk {
144144
}
145145

146146
setModules(modules) {
147-
this._modules = new SortableSet(modules, Chunk.sortByIdentifier);
147+
this._modules = new SortableSet(modules, sortByIdentifier);
148148
}
149149

150150
getNumberOfModules() {
@@ -422,7 +422,7 @@ class Chunk {
422422
}
423423

424424
sortItems() {
425-
this._modules.sortWith(Chunk.sortById);
425+
this._modules.sortWith(sortById);
426426
this.origins.sort((a, b) => {
427427
const aIdent = a.module.identifier();
428428
const bIdent = b.module.identifier();
@@ -434,8 +434,8 @@ class Chunk {
434434
if(origin.reasons)
435435
origin.reasons.sort();
436436
});
437-
this.parents.sort(Chunk.sortById);
438-
this.chunks.sort(Chunk.sortById);
437+
this.parents.sort(sortById);
438+
this.chunks.sort(sortById);
439439
}
440440

441441
toString() {

lib/Module.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ const Template = require("./Template");
1313

1414
let debugId = 1000;
1515

16-
class Module extends DependenciesBlock {
16+
const sortById = (a, b) => {
17+
return a.id - b.id;
18+
};
1719

18-
static sortById(a, b) {
19-
return a.id - b.id;
20-
}
20+
const sortByDebugId = (a, b) => {
21+
return a.debugId - b.debugId;
22+
};
2123

22-
static sortByDebugId(a, b) {
23-
return a.debugId - b.debugId;
24-
}
24+
class Module extends DependenciesBlock {
2525

2626
constructor() {
2727
super();
@@ -37,7 +37,7 @@ class Module extends DependenciesBlock {
3737
this.used = null;
3838
this.usedExports = null;
3939
this.providedExports = null;
40-
this._chunks = new SortableSet(undefined, Module.sortById);
40+
this._chunks = new SortableSet(undefined, sortById);
4141
this._chunksDebugIdent = undefined;
4242
this.warnings = [];
4343
this.dependenciesWarnings = [];
@@ -94,7 +94,7 @@ class Module extends DependenciesBlock {
9494

9595
getChunkIdsIdent() {
9696
if(this._chunksDebugIdent !== undefined) return this._chunksDebugIdent;
97-
this._chunks.sortWith(Module.sortByDebugId);
97+
this._chunks.sortWith(sortByDebugId);
9898
const chunks = this._chunks;
9999
const list = [];
100100
for(const chunk of chunks) {
@@ -128,8 +128,8 @@ class Module extends DependenciesBlock {
128128

129129
hasEqualsChunks(otherModule) {
130130
if(this._chunks.size !== otherModule._chunks.size) return false;
131-
this._chunks.sortWith(Module.sortByDebugId);
132-
otherModule._chunks.sortWith(Module.sortByDebugId);
131+
this._chunks.sortWith(sortByDebugId);
132+
otherModule._chunks.sortWith(sortByDebugId);
133133
const a = this._chunks[Symbol.iterator]();
134134
const b = otherModule._chunks[Symbol.iterator]();
135135
while(true) { // eslint-disable-line
@@ -206,7 +206,7 @@ class Module extends DependenciesBlock {
206206
super.sortItems();
207207
if(sortChunks)
208208
this._chunks.sort();
209-
this.reasons.sort((a, b) => Module.sortById(a.module, b.module));
209+
this.reasons.sort((a, b) => sortById(a.module, b.module));
210210
if(Array.isArray(this.usedExports)) {
211211
this.usedExports.sort();
212212
}

0 commit comments

Comments
 (0)