Skip to content

Commit fad4021

Browse files
committed
rename d to a readable name
1 parent fae5bec commit fad4021

1 file changed

Lines changed: 30 additions & 30 deletions

File tree

‎lib/Stats.js‎

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const RequestShortener = require("./RequestShortener");
88
const SizeFormatHelpers = require("./SizeFormatHelpers");
99
const formatLocation = require("./formatLocation");
1010

11-
const d = (v, def) => v === undefined ? def : v;
11+
const optionOrFallback = (optionValue, fallbackValue) => optionValue !== undefined ? optionValue : fallbackValue;
1212

1313
class Stats {
1414
constructor(compilation) {
@@ -39,37 +39,37 @@ class Stats {
3939
}
4040

4141
const compilation = this.compilation;
42-
const requestShortener = new RequestShortener(d(options.context, process.cwd()));
43-
const showPerformance = d(options.performance, true);
44-
const showHash = d(options.hash, true);
45-
const showVersion = d(options.version, true);
46-
const showTimings = d(options.timings, true);
47-
const showAssets = d(options.assets, true);
48-
const showEntrypoints = d(options.entrypoints, !forToString);
49-
const showChunks = d(options.chunks, true);
50-
const showChunkModules = d(options.chunkModules, !!forToString);
51-
const showChunkOrigins = d(options.chunkOrigins, !forToString);
52-
const showModules = d(options.modules, !forToString);
53-
const showDepth = d(options.depth, !forToString);
54-
const showCachedModules = d(options.cached, true);
55-
const showCachedAssets = d(options.cachedAssets, true);
56-
const showReasons = d(options.reasons, !forToString);
57-
const showUsedExports = d(options.usedExports, !forToString);
58-
const showProvidedExports = d(options.providedExports, !forToString);
59-
const showChildren = d(options.children, true);
60-
const showSource = d(options.source, !forToString);
61-
const showErrors = d(options.errors, true);
62-
const showErrorDetails = d(options.errorDetails, !forToString);
63-
const showWarnings = d(options.warnings, true);
64-
const showPublicPath = d(options.publicPath, !forToString);
65-
const excludeModules = [].concat(d(options.exclude, [])).map(str => {
42+
const requestShortener = new RequestShortener(optionOrFallback(options.context, process.cwd()));
43+
const showPerformance = optionOrFallback(options.performance, true);
44+
const showHash = optionOrFallback(options.hash, true);
45+
const showVersion = optionOrFallback(options.version, true);
46+
const showTimings = optionOrFallback(options.timings, true);
47+
const showAssets = optionOrFallback(options.assets, true);
48+
const showEntrypoints = optionOrFallback(options.entrypoints, !forToString);
49+
const showChunks = optionOrFallback(options.chunks, true);
50+
const showChunkModules = optionOrFallback(options.chunkModules, !!forToString);
51+
const showChunkOrigins = optionOrFallback(options.chunkOrigins, !forToString);
52+
const showModules = optionOrFallback(options.modules, !forToString);
53+
const showDepth = optionOrFallback(options.depth, !forToString);
54+
const showCachedModules = optionOrFallback(options.cached, true);
55+
const showCachedAssets = optionOrFallback(options.cachedAssets, true);
56+
const showReasons = optionOrFallback(options.reasons, !forToString);
57+
const showUsedExports = optionOrFallback(options.usedExports, !forToString);
58+
const showProvidedExports = optionOrFallback(options.providedExports, !forToString);
59+
const showChildren = optionOrFallback(options.children, true);
60+
const showSource = optionOrFallback(options.source, !forToString);
61+
const showErrors = optionOrFallback(options.errors, true);
62+
const showErrorDetails = optionOrFallback(options.errorDetails, !forToString);
63+
const showWarnings = optionOrFallback(options.warnings, true);
64+
const showPublicPath = optionOrFallback(options.publicPath, !forToString);
65+
const excludeModules = [].concat(optionOrFallback(options.exclude, [])).map(str => {
6666
if(typeof str !== "string") return str;
6767
return new RegExp(`[\\\\/]${str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&")}([\\\\/]|$|!|\\?)`);
6868
});
69-
const maxModules = d(options.maxModules, forToString ? 15 : Infinity);
70-
const sortModules = d(options.modulesSort, "id");
71-
const sortChunks = d(options.chunksSort, "id");
72-
const sortAssets = d(options.assetsSort, "");
69+
const maxModules = optionOrFallback(options.maxModules, forToString ? 15 : Infinity);
70+
const sortModules = optionOrFallback(options.modulesSort, "id");
71+
const sortChunks = optionOrFallback(options.chunksSort, "id");
72+
const sortAssets = optionOrFallback(options.assetsSort, "");
7373

7474
const createModuleFilter = () => {
7575
let i = 0;
@@ -344,7 +344,7 @@ class Stats {
344344
options = {};
345345
}
346346

347-
const useColors = d(options.colors, false);
347+
const useColors = optionOrFallback(options.colors, false);
348348

349349
const obj = this.toJson(options, true);
350350

0 commit comments

Comments
 (0)