mirror of https://github.com/webpack/webpack.git
make sort function private
This commit is contained in:
parent
bd8c6cf158
commit
1a16a3e181
34
lib/Chunk.js
34
lib/Chunk.js
|
|
@ -9,26 +9,26 @@ const compareLocations = require("./compareLocations");
|
|||
const SortableSet = require("./util/SortableSet");
|
||||
let debugId = 1000;
|
||||
|
||||
const sortById = (a, b) => {
|
||||
if(a.id < b.id) return -1;
|
||||
if(b.id < a.id) return 1;
|
||||
return 0;
|
||||
};
|
||||
|
||||
const sortByIdentifier = (a, b) => {
|
||||
if(a.identifier() > b.identifier()) return 1;
|
||||
if(a.identifier() < b.identifier()) return -1;
|
||||
return 0;
|
||||
};
|
||||
|
||||
class Chunk {
|
||||
|
||||
static sortById(a, b) {
|
||||
if(a.id < b.id) return -1;
|
||||
if(b.id < a.id) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static sortByIdentifier(a, b) {
|
||||
if(a.identifier() > b.identifier()) return 1;
|
||||
if(a.identifier() < b.identifier()) return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
constructor(name, module, loc) {
|
||||
this.id = null;
|
||||
this.ids = null;
|
||||
this.debugId = debugId++;
|
||||
this.name = name;
|
||||
this._modules = new SortableSet(undefined, Chunk.sortByIdentifier);
|
||||
this._modules = new SortableSet(undefined, sortByIdentifier);
|
||||
this.entrypoints = [];
|
||||
this.chunks = [];
|
||||
this.parents = [];
|
||||
|
|
@ -144,7 +144,7 @@ class Chunk {
|
|||
}
|
||||
|
||||
setModules(modules) {
|
||||
this._modules = new SortableSet(modules, Chunk.sortByIdentifier);
|
||||
this._modules = new SortableSet(modules, sortByIdentifier);
|
||||
}
|
||||
|
||||
getNumberOfModules() {
|
||||
|
|
@ -422,7 +422,7 @@ class Chunk {
|
|||
}
|
||||
|
||||
sortItems() {
|
||||
this._modules.sortWith(Chunk.sortById);
|
||||
this._modules.sortWith(sortById);
|
||||
this.origins.sort((a, b) => {
|
||||
const aIdent = a.module.identifier();
|
||||
const bIdent = b.module.identifier();
|
||||
|
|
@ -434,8 +434,8 @@ class Chunk {
|
|||
if(origin.reasons)
|
||||
origin.reasons.sort();
|
||||
});
|
||||
this.parents.sort(Chunk.sortById);
|
||||
this.chunks.sort(Chunk.sortById);
|
||||
this.parents.sort(sortById);
|
||||
this.chunks.sort(sortById);
|
||||
}
|
||||
|
||||
toString() {
|
||||
|
|
|
|||
|
|
@ -13,16 +13,16 @@ const Template = require("./Template");
|
|||
|
||||
let debugId = 1000;
|
||||
|
||||
const sortById = (a, b) => {
|
||||
return a.id - b.id;
|
||||
};
|
||||
|
||||
const sortByDebugId = (a, b) => {
|
||||
return a.debugId - b.debugId;
|
||||
};
|
||||
|
||||
class Module extends DependenciesBlock {
|
||||
|
||||
static sortById(a, b) {
|
||||
return a.id - b.id;
|
||||
}
|
||||
|
||||
static sortByDebugId(a, b) {
|
||||
return a.debugId - b.debugId;
|
||||
}
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.context = null;
|
||||
|
|
@ -37,7 +37,7 @@ class Module extends DependenciesBlock {
|
|||
this.used = null;
|
||||
this.usedExports = null;
|
||||
this.providedExports = null;
|
||||
this._chunks = new SortableSet(undefined, Module.sortById);
|
||||
this._chunks = new SortableSet(undefined, sortById);
|
||||
this._chunksDebugIdent = undefined;
|
||||
this.warnings = [];
|
||||
this.dependenciesWarnings = [];
|
||||
|
|
@ -94,7 +94,7 @@ class Module extends DependenciesBlock {
|
|||
|
||||
getChunkIdsIdent() {
|
||||
if(this._chunksDebugIdent !== undefined) return this._chunksDebugIdent;
|
||||
this._chunks.sortWith(Module.sortByDebugId);
|
||||
this._chunks.sortWith(sortByDebugId);
|
||||
const chunks = this._chunks;
|
||||
const list = [];
|
||||
for(const chunk of chunks) {
|
||||
|
|
@ -128,8 +128,8 @@ class Module extends DependenciesBlock {
|
|||
|
||||
hasEqualsChunks(otherModule) {
|
||||
if(this._chunks.size !== otherModule._chunks.size) return false;
|
||||
this._chunks.sortWith(Module.sortByDebugId);
|
||||
otherModule._chunks.sortWith(Module.sortByDebugId);
|
||||
this._chunks.sortWith(sortByDebugId);
|
||||
otherModule._chunks.sortWith(sortByDebugId);
|
||||
const a = this._chunks[Symbol.iterator]();
|
||||
const b = otherModule._chunks[Symbol.iterator]();
|
||||
while(true) { // eslint-disable-line
|
||||
|
|
@ -206,7 +206,7 @@ class Module extends DependenciesBlock {
|
|||
super.sortItems();
|
||||
if(sortChunks)
|
||||
this._chunks.sort();
|
||||
this.reasons.sort((a, b) => Module.sortById(a.module, b.module));
|
||||
this.reasons.sort((a, b) => sortById(a.module, b.module));
|
||||
if(Array.isArray(this.usedExports)) {
|
||||
this.usedExports.sort();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue