Skip to content

Commit

Permalink
revert function style, fix a few types, etc
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLarkInn committed Jun 23, 2018
1 parent b47cff9 commit f64f75e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 22 deletions.
32 changes: 14 additions & 18 deletions lib/Compilation.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,63 +102,63 @@ const ModuleDependency = require("./dependencies/ModuleDependency");
* @param {Chunk} b second chunk to sort by id
* @returns {-1|0|1} sort value
*/
function byId(a, b) {
if (a.id && b.id) {
const byId = (a, b) => {
if (a.id !== null && b.id !== null) {
if (a.id < b.id) return -1;
if (a.id > b.id) return 1;
}
return 0;
}
};

/**
* @param {Module} a first module to sort by
* @param {Module} b second module to sort by
* @returns {-1|0|1} sort value
*/
function byIdOrIdentifier(a, b) {
const byIdOrIdentifier = (a, b) => {
if (a.id < b.id) return -1;
if (a.id > b.id) return 1;
const identA = a.identifier();
const identB = b.identifier();
if (identA < identB) return -1;
if (identA > identB) return 1;
return 0;
}
};

/**
* @param {Module} a first module to sort by
* @param {Module} b second module to sort by
* @returns {-1|0|1} sort value
*/
function byIndexOrIdentifier(a, b) {
const byIndexOrIdentifier = (a, b) => {
if (a.index < b.index) return -1;
if (a.index > b.index) return 1;
const identA = a.identifier();
const identB = b.identifier();
if (identA < identB) return -1;
if (identA > identB) return 1;
return 0;
}
};

/**
* @param {Compilation} a first compilation to sort by
* @param {Compilation} b second compilation to sort by
* @returns {-1|0|1} sort value
*/
function byNameOrHash(a, b) {
const byNameOrHash = (a, b) => {
if (a.name < b.name) return -1;
if (a.name > b.name) return 1;
if (a.fullHash < b.fullHash) return -1;
if (a.fullHash > b.fullHash) return 1;
return 0;
}
};

/**
* @param {DependenciesBlockVariable[]} variables DepBlock Variables to iterate over
* @param {DepBlockVarDependenciesCallback} fn callback to apply on iterated elements
* @returns {void}
*/
function iterationBlockVariable(variables, fn) {
const iterationBlockVariable = (variables, fn) => {
for (
let indexVariable = 0;
indexVariable < variables.length;
Expand All @@ -171,22 +171,22 @@ function iterationBlockVariable(variables, fn) {
fn(varDep[indexVDep]);
}
}
}
};

/**
* @template {T}
* @param {T[]} arr array of elements to iterate over
* @param {function(T): void} fn callback applied to each element
* @returns {void}
*/
function iterationOfArrayCallback(arr, fn) {
const iterationOfArrayCallback = (arr, fn) => {
for (let index = 0; index < arr.length; index++) {
fn(arr[index]);
}
}
};

/**
* @template {T}
* @template T
* @param {Set<T>} set set to add items to
* @param {Set<T>} otherSet set to add items from
* @returns {void}
Expand Down Expand Up @@ -928,7 +928,6 @@ class Compilation extends Tapable {
}

this.semaphore.acquire(() => {
/** @type {ModuleFactory} */
moduleFactory.create(
{
contextInfo: {
Expand Down Expand Up @@ -2011,9 +2010,6 @@ class Compilation extends Tapable {
// Calculate maximum assigned chunk id
let nextFreeChunkId = -1;
for (const id of usedIds) {
if (typeof id !== "number") {
continue;
}
nextFreeChunkId = Math.max(nextFreeChunkId, id);
}
nextFreeChunkId++;
Expand Down
2 changes: 1 addition & 1 deletion lib/Compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const ConcurrentCompilationError = require("./ConcurrentCompilationError");
* @typedef {Object} CompilationParams
* @property {NormalModuleFactory} normalModuleFactory
* @property {ContextModuleFactory} contextModuleFactory
* @property {Set<any>} compilationDependencies
* @property {Set<string>} compilationDependencies
*/

/** @typedef {string|string[]} EntryValues */
Expand Down
6 changes: 3 additions & 3 deletions test/__snapshots__/StatsTestCases.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ exports[`StatsTestCases should print correct stats for aggressive-splitting-on-d
Time: Xms
Built at: Thu Jan 01 1970 00:00:00 GMT
Asset Size Chunks Chunk Names
cf8697fa2c994f39a5d4.js 1.94 KiB 6, 7 [emitted]
fd868baa40dab4fc30fd.js 1.93 KiB 0 [emitted]
d6418937dfae4b3ee922.js 1 KiB 1 [emitted]
79c527bb5bf9cba1dc12.js 1.96 KiB 2 [emitted]
e9d82e81fefd7353e8df.js 1.94 KiB 3, 1 [emitted]
ae76098eeb55b9c448f2.js 1.01 KiB 4 [emitted]
05d92aaacfbffa4b7e56.js 1.94 KiB 5 [emitted]
cf8697fa2c994f39a5d4.js 1.94 KiB 6, 7 [emitted]
79c527bb5bf9cba1dc12.js 1.96 KiB 2 [emitted]
d6418937dfae4b3ee922.js 1 KiB 1 [emitted]
685acdc95ff4af957f47.js 1 KiB 7 [emitted]
606f48c13070850338b1.js 1.94 KiB 8 [emitted]
c5a8eae840969538f450.js 1.94 KiB 9 [emitted]
Expand Down

0 comments on commit f64f75e

Please sign in to comment.