From ef1f82ffa86da1148e5b4a77adca085842592208 Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Mon, 23 Dec 2024 15:00:06 +0100 Subject: [PATCH 01/11] cleanup --- about.html | 228 +++++++++++++++++++++++++++++++++++++++++++++ resources/main.css | 43 ++++++++- 2 files changed, 267 insertions(+), 4 deletions(-) diff --git a/about.html b/about.html index 77f1c2933..2e06574ef 100644 --- a/about.html +++ b/about.html @@ -91,6 +91,234 @@

About Speedometer 3

built as static files ahead of time. + +

Score and Test Measurement

+

+ Each test can contain several steps who contributed to the test duration. Note that the prepare step of a test is unmeasured and thus does not contribute to the score. All following test + steps are measured and summed up in the test step time. +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Iteration:Iteration 1...Iteration N
Test:TodoMVC-JavaScript-ES5...Perf-DashboardTodoMVC-......
Steps:PrepareAddingCompleting...Prepare...Prepare...
SyncAsyncSyncAsync
+

+ The final benchmark score is calculated based of the inverse of geomean of all tests. We average the score over multiple iterations with the + arithmetic mean. By using the geomean to combine the test durations we maintain the invariant that relative improvements are favoured equally amongst all tests, + even though they can have vastly different durations. +

+

+ + + + + + Score + + + + + = + + 1 + n + + + + + + i + = + 1 + + n + + + + + IterationScore + + i + + + + + + + + + IterationScore + + i + + + + + = + + 1000 + + + IterationGeoMeanTime + + i + + + + + + + + + + IterationGeoMeanTime + + i + + + + + = + + + + + + + j + = + 1 + + m + + + + + TestTime + + + i + j + + + + m + + + + + + + + + TestTime + + + i + j + + + + + + = + + + + k + + + + + TestStepTime + + + i + j + k + + + + + + + + + + TestStepTime + + + i + j + k + + + + + + = + + + TestStepSyncTime + + + i + j + k + + + + + + + TestStepAsyncTime + + + i + j + k + + + + + + + +

- {title - ?
+ {title ? ( +

{title}

- : null} + ) : null}
{description}
diff --git a/resources/newssite/news-next/src/context/data-context.js b/resources/newssite/news-next/src/context/data-context.js index 61d24a8fe..c7250997a 100644 --- a/resources/newssite/news-next/src/context/data-context.js +++ b/resources/newssite/news-next/src/context/data-context.js @@ -28,8 +28,7 @@ export const DataContextProvider = ({ children }) => { export const useDataContext = () => { const dataContext = useContext(DataContext); - if (!dataContext) - throw new Error("A DataProvider must be rendered before using useDataContext"); + if (!dataContext) throw new Error("A DataProvider must be rendered before using useDataContext"); return dataContext; }; diff --git a/resources/newssite/news-next/src/pages/_app.js b/resources/newssite/news-next/src/pages/_app.js index 820529ccf..ae379be1e 100644 --- a/resources/newssite/news-next/src/pages/_app.js +++ b/resources/newssite/news-next/src/pages/_app.js @@ -10,8 +10,8 @@ import Script from "next/script"; function App({ Component, pageProps }) { const [render, setRender] = useState(false); useEffect(() => setRender(true), []); - return render - ? <> + return render ? ( + <> - : null; + ) : null; } export default App; diff --git a/resources/newssite/news-next/src/partials/page/page.jsx b/resources/newssite/news-next/src/partials/page/page.jsx index c76a4fed2..3a01351ee 100644 --- a/resources/newssite/news-next/src/partials/page/page.jsx +++ b/resources/newssite/news-next/src/partials/page/page.jsx @@ -30,9 +30,9 @@ export default function Page({ id }) { return ( <> - {content[id].sections.map((section) => + {content[id].sections.map((section) => (
- )} + ))} {showPortal && content[id].notification ? createPortal(, document.getElementById("notifications-container")) : null} diff --git a/resources/newssite/news-next/src/partials/section/section.jsx b/resources/newssite/news-next/src/partials/section/section.jsx index df90ffe29..6b7c72609 100644 --- a/resources/newssite/news-next/src/partials/section/section.jsx +++ b/resources/newssite/news-next/src/partials/section/section.jsx @@ -5,15 +5,15 @@ import styles from "news-site-css/dist/layout.module.css"; export default function Section({ section }) { return ( <> - {section.name - ?
+ {section.name ? ( +

{section.name}

- : null} + ) : null}
- {section.articles.map((article, index) => + {section.articles.map((article, index) => (
- )} + ))}
); diff --git a/resources/scripts/sanitize-language/index.js b/resources/scripts/sanitize-language/index.js index b0d4c5ab9..e4f62b624 100644 --- a/resources/scripts/sanitize-language/index.js +++ b/resources/scripts/sanitize-language/index.js @@ -31,8 +31,7 @@ async function readAndReplace(fileName) { return replacements.get(matched); }); - if (contents !== sanitized) - await fs.writeFile(fileName, sanitized); + if (contents !== sanitized) await fs.writeFile(fileName, sanitized); } async function sanitize() { diff --git a/resources/shared/benchmark.mjs b/resources/shared/benchmark.mjs index b691e86ac..e9939fdcb 100644 --- a/resources/shared/benchmark.mjs +++ b/resources/shared/benchmark.mjs @@ -86,23 +86,20 @@ export class BenchmarkConnector { this.name = name; this.version = version; - if (!name || !version) - console.warn("No name or version supplied, to create a unique appId"); + if (!name || !version) console.warn("No name or version supplied, to create a unique appId"); this.appId = name && version ? `${name}-${version}` : -1; this.onMessage = this.onMessage.bind(this); } async onMessage(event) { - if (event.data.id !== this.appId || event.data.key !== "benchmark-connector") - return; + if (event.data.id !== this.appId || event.data.key !== "benchmark-connector") return; switch (event.data.type) { case "benchmark-suite": const params = new Params(new URLSearchParams(window.location.search)); const suite = this.suites[event.data.name]; - if (!suite) - console.error(`Suite with the name of "${event.data.name}" not found!`); + if (!suite) console.error(`Suite with the name of "${event.data.name}" not found!`); const { result } = await suite.runAndRecord(params, (test) => this.sendMessage({ type: "step-complete", status: "success", appId: this.appId, name: this.name, test })); this.sendMessage({ type: "suite-complete", status: "success", appId: this.appId, result }); this.disconnect(); diff --git a/resources/shared/params.mjs b/resources/shared/params.mjs index 57b3adc52..325e49f41 100644 --- a/resources/shared/params.mjs +++ b/resources/shared/params.mjs @@ -27,8 +27,7 @@ export class Params { shuffleSeed = "off"; constructor(searchParams = undefined) { - if (searchParams) - this._copyFromSearchParams(searchParams); + if (searchParams) this._copyFromSearchParams(searchParams); if (!this.developerMode) { Object.freeze(this.viewport); Object.freeze(this); @@ -37,8 +36,7 @@ export class Params { _parseInt(value, errorMessage) { const number = Number(value); - if (!Number.isInteger(number) && errorMessage) - throw new Error(`Invalid ${errorMessage} param: '${value}', expected int.`); + if (!Number.isInteger(number) && errorMessage) throw new Error(`Invalid ${errorMessage} param: '${value}', expected int.`); return parseInt(number); } @@ -56,51 +54,43 @@ export class Params { this.shuffleSeed = this._parseShuffleSeed(searchParams); const unused = Array.from(searchParams.keys()); - if (unused.length > 0) - console.error("Got unused search params", unused); + if (unused.length > 0) console.error("Got unused search params", unused); } _parseBooleanParam(searchParams, paramKey) { - if (!searchParams.has(paramKey)) - return false; + if (!searchParams.has(paramKey)) return false; searchParams.delete(paramKey); return true; } _parseIntParam(searchParams, paramKey, minValue) { - if (!searchParams.has(paramKey)) - return defaultParams[paramKey]; + if (!searchParams.has(paramKey)) return defaultParams[paramKey]; const parsedValue = this._parseInt(searchParams.get(paramKey), "waitBeforeSync"); - if (parsedValue < minValue) - throw new Error(`Invalid ${paramKey} param: '${parsedValue}', value must be >= ${minValue}.`); + if (parsedValue < minValue) throw new Error(`Invalid ${paramKey} param: '${parsedValue}', value must be >= ${minValue}.`); searchParams.delete(paramKey); return parsedValue; } _parseViewport(searchParams) { - if (!searchParams.has("viewport")) - return defaultParams.viewport; + if (!searchParams.has("viewport")) return defaultParams.viewport; const viewportParam = searchParams.get("viewport"); const [width, height] = viewportParam.split("x"); const viewport = { width: this._parseInt(width, "viewport.width"), height: this._parseInt(height, "viewport.height"), }; - if (this.viewport.width < 800 || this.viewport.height < 600) - throw new Error(`Invalid viewport param: ${viewportParam}`); + if (this.viewport.width < 800 || this.viewport.height < 600) throw new Error(`Invalid viewport param: ${viewportParam}`); searchParams.delete("viewport"); return viewport; } _parseSuites(searchParams) { if (searchParams.has("suite") || searchParams.has("suites")) { - if (searchParams.has("suite") && searchParams.has("suites")) - throw new Error("Params 'suite' and 'suites' can not be used together."); + if (searchParams.has("suite") && searchParams.has("suites")) throw new Error("Params 'suite' and 'suites' can not be used together."); const value = searchParams.get("suite") || searchParams.get("suites"); const suites = value.split(","); - if (suites.length === 0) - throw new Error("No suites selected"); + if (suites.length === 0) throw new Error("No suites selected"); searchParams.delete("suite"); searchParams.delete("suites"); return suites; @@ -109,28 +99,23 @@ export class Params { } _parseTags(searchParams) { - if (!searchParams.has("tags")) - return defaultParams.tags; - if (this.suites.length) - throw new Error("'suites' and 'tags' cannot be used together."); + if (!searchParams.has("tags")) return defaultParams.tags; + if (this.suites.length) throw new Error("'suites' and 'tags' cannot be used together."); const tags = searchParams.get("tags").split(","); searchParams.delete("tags"); return tags; } _parseMeasurementMethod(searchParams) { - if (!searchParams.has("measurementMethod")) - return defaultParams.measurementMethod; + if (!searchParams.has("measurementMethod")) return defaultParams.measurementMethod; const measurementMethod = searchParams.get("measurementMethod"); - if (measurementMethod !== "raf") - throw new Error(`Invalid measurement method: '${measurementMethod}', must be 'raf'.`); + if (measurementMethod !== "raf") throw new Error(`Invalid measurement method: '${measurementMethod}', must be 'raf'.`); searchParams.delete("measurementMethod"); return measurementMethod; } _parseShuffleSeed(searchParams) { - if (!searchParams.has("shuffleSeed")) - return defaultParams.shuffleSeed; + if (!searchParams.has("shuffleSeed")) return defaultParams.shuffleSeed; let shuffleSeed = searchParams.get("shuffleSeed"); if (shuffleSeed !== "off") { if (shuffleSeed === "generate") { @@ -139,8 +124,7 @@ export class Params { } else { shuffleSeed = parseInt(shuffleSeed); } - if (!Number.isInteger(shuffleSeed)) - throw new Error(`Invalid shuffle seed: '${shuffleSeed}', must be either 'off', 'generate' or an integer.`); + if (!Number.isInteger(shuffleSeed)) throw new Error(`Invalid shuffle seed: '${shuffleSeed}', must be either 'off', 'generate' or an integer.`); } searchParams.delete("shuffleSeed"); return shuffleSeed; @@ -149,14 +133,12 @@ export class Params { toSearchParamsObject() { const rawParams = { __proto__: null }; for (const [key, value] of Object.entries(this)) { - if (value === defaultParams[key]) - continue; + if (value === defaultParams[key]) continue; rawParams[key] = value; } // Either suites or params can be used at the same time. - if (rawParams.suites?.length && rawParams.tags?.length) - delete rawParams.suites; + if (rawParams.suites?.length && rawParams.tags?.length) delete rawParams.suites; rawParams.viewport = `${this.viewport.width}x${this.viewport.height}`; return new URLSearchParams(rawParams); diff --git a/resources/shared/test-invoker.mjs b/resources/shared/test-invoker.mjs index c20c40b8f..413b00fd4 100644 --- a/resources/shared/test-invoker.mjs +++ b/resources/shared/test-invoker.mjs @@ -10,10 +10,8 @@ class TestInvoker { export class RAFTestInvoker extends TestInvoker { start() { return new Promise((resolve) => { - if (this._params.waitBeforeSync) - setTimeout(() => this._scheduleCallbacks(resolve), this._params.waitBeforeSync); - else - this._scheduleCallbacks(resolve); + if (this._params.waitBeforeSync) setTimeout(() => this._scheduleCallbacks(resolve), this._params.waitBeforeSync); + else this._scheduleCallbacks(resolve); }); } diff --git a/resources/shared/test-runner.mjs b/resources/shared/test-runner.mjs index 1b5c2598e..c5cd0894e 100644 --- a/resources/shared/test-runner.mjs +++ b/resources/shared/test-runner.mjs @@ -36,8 +36,7 @@ export class TestRunner { performance.mark("warmup-start"); const startTime = performance.now(); // Infinite loop for the specified ms. - while (performance.now() - startTime < this.#params.warmupBeforeSync) - continue; + while (performance.now() - startTime < this.#params.warmupBeforeSync) continue; performance.mark("warmup-end"); } performance.mark(syncStartLabel); @@ -64,8 +63,7 @@ export class TestRunner { asyncTime = asyncEndTime - asyncStartTime; - if (this.#params.warmupBeforeSync) - performance.measure("warmup", "warmup-start", "warmup-end"); + if (this.#params.warmupBeforeSync) performance.measure("warmup", "warmup-start", "warmup-end"); performance.measure(`${suiteName}.${testName}-sync`, syncStartLabel, syncEndLabel); performance.measure(`${suiteName}.${testName}-async`, asyncStartLabel, asyncEndLabel); }; diff --git a/resources/statistics.mjs b/resources/statistics.mjs index ba3018a12..35350e2c8 100644 --- a/resources/statistics.mjs +++ b/resources/statistics.mjs @@ -46,15 +46,13 @@ export function squareSum(values) { // With sum and sum of squares, we can compute the sample standard deviation in O(1). // See https://rniwa.com/2012-11-10/sample-standard-deviation-in-terms-of-sum-and-square-sum-of-samples/ export function sampleStandardDeviation(numberOfSamples, sum, squareSum) { - if (numberOfSamples < 2) - return 0; + if (numberOfSamples < 2) return 0; return Math.sqrt(squareSum / (numberOfSamples - 1) - (sum * sum) / (numberOfSamples - 1) / numberOfSamples); } export function supportedConfidenceLevels() { const supportedLevels = []; - for (let quantile in tDistributionInverseCDF) - supportedLevels.push((1 - (1 - quantile) * 2).toFixed(2)); + for (let quantile in tDistributionInverseCDF) supportedLevels.push((1 - (1 - quantile) * 2).toFixed(2)); return supportedLevels; } @@ -65,13 +63,11 @@ export function confidenceIntervalDelta(confidenceLevel, numberOfSamples, sum, s const supportedIntervals = supportedConfidenceLevels().map((level) => `${level * 100}%`); throw `We only support ${supportedIntervals.join(", ")} confidence intervals.`; } - if (numberOfSamples - 2 < 0) - return NaN; + if (numberOfSamples - 2 < 0) return NaN; const cdfForProbability = tDistributionInverseCDF[probability]; let degreesOfFreedom = numberOfSamples - 1; - if (degreesOfFreedom > cdfForProbability.length) - degreesOfFreedom = cdfForProbability.length - 1; + if (degreesOfFreedom > cdfForProbability.length) degreesOfFreedom = cdfForProbability.length - 1; // tDistributionQuantile(degreesOfFreedom, confidenceLevel) * sampleStandardDeviation / sqrt(numberOfSamples) * S/sqrt(numberOfSamples) const quantile = cdfForProbability[degreesOfFreedom - 1]; // The first entry is for the one degree of freedom. diff --git a/resources/suite-runner.mjs b/resources/suite-runner.mjs index 0daf616ec..e366f51f5 100644 --- a/resources/suite-runner.mjs +++ b/resources/suite-runner.mjs @@ -72,8 +72,7 @@ export class SuiteRunner { performance.mark(suiteStartLabel); for (const test of this.#suite.tests) { - if (this.#client?.willRunTest) - await this.#client.willRunTest(this.#suite, test); + if (this.#client?.willRunTest) await this.#client.willRunTest(this.#suite, test); const testRunner = new TestRunner(this.#frame, this.#page, this.#params, this.#suite, test, this._recordTestResults); await testRunner.runTest(); @@ -90,8 +89,7 @@ export class SuiteRunner { // privacy.resistFingerprinting preference), it's possible that the measured // total duration for an entire is 0. const suiteTotal = this.#suiteResults.total; - if (suiteTotal === 0) - throw new Error(`Got invalid 0-time total for suite ${this.#suite.name}: ${suiteTotal}`); + if (suiteTotal === 0) throw new Error(`Got invalid 0-time total for suite ${this.#suite.name}: ${suiteTotal}`); } async _loadFrame() { @@ -105,8 +103,7 @@ export class SuiteRunner { _recordTestResults = async (test, syncTime, asyncTime) => { // Skip reporting updates for the warmup suite. - if (this.#suite === WarmupSuite) - return; + if (this.#suite === WarmupSuite) return; const total = syncTime + asyncTime; this.#suiteResults.tests[test.name] = { tests: { Sync: syncTime, Async: asyncTime }, total: total }; @@ -114,8 +111,7 @@ export class SuiteRunner { }; async _updateClient(suite = this.#suite) { - if (this.#client?.didFinishSuite) - await this.#client.didFinishSuite(suite); + if (this.#client?.didFinishSuite) await this.#client.didFinishSuite(suite); } } @@ -183,20 +179,17 @@ export class RemoteSuiteRunner extends SuiteRunner { _handlePostMessage(event) { const callback = this.postMessageCallbacks.get(event.data.type); - if (callback) - callback(event); + if (callback) callback(event); } _startSubscription(type, callback) { - if (this.postMessageCallbacks.has(type)) - throw new Error("Callback exists already"); + if (this.postMessageCallbacks.has(type)) throw new Error("Callback exists already"); this.postMessageCallbacks.set(type, callback); } _stopSubscription(type) { - if (!this.postMessageCallbacks.has(type)) - throw new Error("Callback does not exist"); + if (!this.postMessageCallbacks.has(type)) throw new Error("Callback does not exist"); this.postMessageCallbacks.delete(type); } diff --git a/resources/tests.mjs b/resources/tests.mjs index d7cf6794a..158e2b6a8 100644 --- a/resources/tests.mjs +++ b/resources/tests.mjs @@ -16,15 +16,12 @@ Suites.enable = function (names, tags) { if (names?.length) { const lowerCaseNames = names.map((each) => each.toLowerCase()); this.forEach((suite) => { - if (lowerCaseNames.includes(suite.name.toLowerCase())) - suite.disabled = false; - else - suite.disabled = true; + if (lowerCaseNames.includes(suite.name.toLowerCase())) suite.disabled = false; + else suite.disabled = true; }); } else if (tags?.length) { tags.forEach((tag) => { - if (!Tags.has(tag)) - console.error(`Unknown Suites tag: "${tag}"`); + if (!Tags.has(tag)) console.error(`Unknown Suites tag: "${tag}"`); }); const tagsSet = new Set(tags); this.forEach((suite) => { @@ -36,8 +33,7 @@ Suites.enable = function (names, tags) { suite.disabled = !("default" in suite.tags); }); } - if (this.some((suite) => !suite.disabled)) - return; + if (this.some((suite) => !suite.disabled)) return; let message, debugInfo; if (names?.length) { message = `Suites "${names}" does not match any Suite. No tests to run.`; @@ -76,13 +72,11 @@ Suites.push({ }), new BenchmarkTestStep("CompletingAllItems", (page) => { const checkboxes = page.querySelectorAll(".toggle"); - for (let i = 0; i < numberOfItemsToAdd; i++) - checkboxes[i].click(); + for (let i = 0; i < numberOfItemsToAdd; i++) checkboxes[i].click(); }), new BenchmarkTestStep("DeletingAllItems", (page) => { const deleteButtons = page.querySelectorAll(".destroy"); - for (let i = numberOfItemsToAdd - 1; i >= 0; i--) - deleteButtons[i].click(); + for (let i = numberOfItemsToAdd - 1; i >= 0; i--) deleteButtons[i].click(); }), ], }); @@ -139,13 +133,11 @@ Suites.push({ }), new BenchmarkTestStep("CompletingAllItems", (page) => { const checkboxes = page.querySelectorAll(".toggle"); - for (let i = 0; i < numberOfItemsToAdd; i++) - checkboxes[i].click(); + for (let i = 0; i < numberOfItemsToAdd; i++) checkboxes[i].click(); }), new BenchmarkTestStep("DeletingAllItems", (page) => { const deleteButtons = page.querySelectorAll(".destroy"); - for (let i = numberOfItemsToAdd - 1; i >= 0; i--) - deleteButtons[i].click(); + for (let i = numberOfItemsToAdd - 1; i >= 0; i--) deleteButtons[i].click(); }), ], }); @@ -169,13 +161,11 @@ Suites.push({ }), new BenchmarkTestStep("CompletingAllItems", (page) => { const checkboxes = page.querySelectorAll(".toggle"); - for (let i = 0; i < numberOfItemsToAdd; i++) - checkboxes[i].click(); + for (let i = 0; i < numberOfItemsToAdd; i++) checkboxes[i].click(); }), new BenchmarkTestStep("DeletingAllItems", (page) => { const deleteButtons = page.querySelectorAll(".destroy"); - for (let i = numberOfItemsToAdd - 1; i >= 0; i--) - deleteButtons[i].click(); + for (let i = numberOfItemsToAdd - 1; i >= 0; i--) deleteButtons[i].click(); }), ], }); @@ -200,13 +190,11 @@ Suites.push({ }), new BenchmarkTestStep("CompletingAllItems", (page) => { const checkboxes = page.querySelectorAll(".toggle"); - for (let i = 0; i < numberOfItemsToAdd; i++) - checkboxes[i].click(); + for (let i = 0; i < numberOfItemsToAdd; i++) checkboxes[i].click(); }), new BenchmarkTestStep("DeletingAllItems", (page) => { const deleteButtons = page.querySelectorAll(".destroy"); - for (let i = numberOfItemsToAdd - 1; i >= 0; i--) - deleteButtons[i].click(); + for (let i = numberOfItemsToAdd - 1; i >= 0; i--) deleteButtons[i].click(); }), ], }); @@ -230,13 +218,11 @@ Suites.push({ }), new BenchmarkTestStep("CompletingAllItems", (page) => { const checkboxes = page.querySelectorAll(".toggle"); - for (let i = 0; i < numberOfItemsToAdd; i++) - checkboxes[i].click(); + for (let i = 0; i < numberOfItemsToAdd; i++) checkboxes[i].click(); }), new BenchmarkTestStep("DeletingAllItems", (page) => { const deleteButtons = page.querySelectorAll(".destroy"); - for (let i = numberOfItemsToAdd - 1; i >= 0; i--) - deleteButtons[i].click(); + for (let i = numberOfItemsToAdd - 1; i >= 0; i--) deleteButtons[i].click(); }), ], }); @@ -328,13 +314,11 @@ Suites.push({ }), new BenchmarkTestStep("CompletingAllItems", (page) => { const checkboxes = page.querySelectorAll(".toggle"); - for (let i = 0; i < numberOfItemsToAdd; i++) - checkboxes[i].click(); + for (let i = 0; i < numberOfItemsToAdd; i++) checkboxes[i].click(); }), new BenchmarkTestStep("DeletingAllItems", (page) => { const deleteButtons = page.querySelectorAll(".destroy"); - for (let i = numberOfItemsToAdd - 1; i >= 0; i--) - deleteButtons[i].click(); + for (let i = numberOfItemsToAdd - 1; i >= 0; i--) deleteButtons[i].click(); }), ], }); @@ -358,13 +342,11 @@ Suites.push({ }), new BenchmarkTestStep("CompletingAllItems", (page) => { const checkboxes = page.querySelectorAll(".toggle"); - for (let i = 0; i < numberOfItemsToAdd; i++) - checkboxes[i].click(); + for (let i = 0; i < numberOfItemsToAdd; i++) checkboxes[i].click(); }), new BenchmarkTestStep("DeletingAllItems", (page) => { const deleteButtons = page.querySelectorAll(".destroy"); - for (let i = numberOfItemsToAdd - 1; i >= 0; i--) - deleteButtons[i].click(); + for (let i = numberOfItemsToAdd - 1; i >= 0; i--) deleteButtons[i].click(); }), ], }); @@ -387,13 +369,11 @@ Suites.push({ }), new BenchmarkTestStep("CompletingAllItems", (page) => { const checkboxes = page.querySelectorAll(".toggle"); - for (let i = 0; i < numberOfItemsToAdd; i++) - checkboxes[i].click(); + for (let i = 0; i < numberOfItemsToAdd; i++) checkboxes[i].click(); }), new BenchmarkTestStep("DeletingAllItems", (page) => { const deleteButtons = page.querySelectorAll(".destroy"); - for (let i = numberOfItemsToAdd - 1; i >= 0; i--) - deleteButtons[i].click(); + for (let i = numberOfItemsToAdd - 1; i >= 0; i--) deleteButtons[i].click(); }), ], }); @@ -417,13 +397,11 @@ Suites.push({ }), new BenchmarkTestStep("CompletingAllItems", (page) => { const checkboxes = page.querySelectorAll(".toggle"); - for (let i = 0; i < numberOfItemsToAdd; i++) - checkboxes[i].click(); + for (let i = 0; i < numberOfItemsToAdd; i++) checkboxes[i].click(); }), new BenchmarkTestStep("DeletingAllItems", (page) => { const deleteButtons = page.querySelectorAll(".destroy"); - for (let i = numberOfItemsToAdd - 1; i >= 0; i--) - deleteButtons[i].click(); + for (let i = numberOfItemsToAdd - 1; i >= 0; i--) deleteButtons[i].click(); }), ], }); @@ -448,13 +426,11 @@ Suites.push({ }), new BenchmarkTestStep("CompletingAllItems", (page) => { const checkboxes = page.querySelectorAll(".toggle"); - for (let i = 0; i < numberOfItemsToAdd; i++) - checkboxes[i].click(); + for (let i = 0; i < numberOfItemsToAdd; i++) checkboxes[i].click(); }), new BenchmarkTestStep("DeletingAllItems", (page) => { const deleteButtons = page.querySelectorAll(".destroy"); - for (let i = numberOfItemsToAdd - 1; i >= 0; i--) - deleteButtons[i].click(); + for (let i = numberOfItemsToAdd - 1; i >= 0; i--) deleteButtons[i].click(); }), ], }); @@ -480,13 +456,11 @@ Suites.push({ }), new BenchmarkTestStep("CompletingAllItems", (page) => { const checkboxes = page.querySelectorAll(".toggle"); - for (let i = 0; i < numberOfItemsToAdd; i++) - checkboxes[i].click(); + for (let i = 0; i < numberOfItemsToAdd; i++) checkboxes[i].click(); }), new BenchmarkTestStep("DeletingAllItems", (page) => { const deleteButtons = page.querySelectorAll(".destroy"); - for (let i = numberOfItemsToAdd - 1; i >= 0; i--) - deleteButtons[i].click(); + for (let i = numberOfItemsToAdd - 1; i >= 0; i--) deleteButtons[i].click(); }), ], }); @@ -511,13 +485,11 @@ Suites.push({ }), new BenchmarkTestStep("CompletingAllItems", (page) => { const checkboxes = page.querySelectorAll(".toggle"); - for (let i = 0; i < numberOfItemsToAdd; i++) - checkboxes[i].click(); + for (let i = 0; i < numberOfItemsToAdd; i++) checkboxes[i].click(); }), new BenchmarkTestStep("DeletingAllItems", (page) => { const deleteButtons = page.querySelectorAll(".destroy"); - for (let i = numberOfItemsToAdd - 1; i >= 0; i--) - deleteButtons[i].click(); + for (let i = numberOfItemsToAdd - 1; i >= 0; i--) deleteButtons[i].click(); }), ], }); @@ -541,13 +513,11 @@ Suites.push({ }), new BenchmarkTestStep("CompletingAllItems", (page) => { const checkboxes = page.querySelectorAll(".toggle"); - for (let i = 0; i < numberOfItemsToAdd; i++) - checkboxes[i].click(); + for (let i = 0; i < numberOfItemsToAdd; i++) checkboxes[i].click(); }), new BenchmarkTestStep("DeletingAllItems", (page) => { const deleteButtons = page.querySelectorAll(".destroy"); - for (let i = numberOfItemsToAdd - 1; i >= 0; i--) - deleteButtons[i].click(); + for (let i = numberOfItemsToAdd - 1; i >= 0; i--) deleteButtons[i].click(); }), ], }); @@ -571,13 +541,11 @@ Suites.push({ }), new BenchmarkTestStep("CompletingAllItems", (page) => { const checkboxes = page.querySelectorAll(".toggle"); - for (let i = 0; i < numberOfItemsToAdd; i++) - checkboxes[i].click(); + for (let i = 0; i < numberOfItemsToAdd; i++) checkboxes[i].click(); }), new BenchmarkTestStep("DeletingAllItems", (page) => { const deleteButtons = page.querySelectorAll(".destroy"); - for (let i = numberOfItemsToAdd - 1; i >= 0; i--) - deleteButtons[i].click(); + for (let i = numberOfItemsToAdd - 1; i >= 0; i--) deleteButtons[i].click(); }), ], }); @@ -602,13 +570,11 @@ Suites.push({ }), new BenchmarkTestStep("CompletingAllItems", (page) => { const checkboxes = page.querySelectorAll(".toggle"); - for (let i = 0; i < numberOfItemsToAdd; i++) - checkboxes[i].click(); + for (let i = 0; i < numberOfItemsToAdd; i++) checkboxes[i].click(); }), new BenchmarkTestStep("DeletingAllItems", (page) => { const deleteButtons = page.querySelectorAll(".destroy"); - for (let i = numberOfItemsToAdd - 1; i >= 0; i--) - deleteButtons[i].click(); + for (let i = numberOfItemsToAdd - 1; i >= 0; i--) deleteButtons[i].click(); }), ], }); @@ -631,12 +597,10 @@ Suites.push({ } }), new BenchmarkTestStep("CompletingAllItems", (page) => { - for (let i = 1; i <= numberOfItemsToAdd; i++) - page.querySelector(`li:nth-child(${i}) .toggle`).click(); + for (let i = 1; i <= numberOfItemsToAdd; i++) page.querySelector(`li:nth-child(${i}) .toggle`).click(); }), new BenchmarkTestStep("DeletingAllItems", (page) => { - for (let i = numberOfItemsToAdd - 1; i >= 0; i--) - page.querySelector(".destroy").click(); + for (let i = numberOfItemsToAdd - 1; i >= 0; i--) page.querySelector(".destroy").click(); }), ], }); @@ -660,12 +624,10 @@ Suites.push({ } }), new BenchmarkTestStep("CompletingAllItems", (page) => { - for (let i = 1; i <= numberOfItemsToAdd; i++) - page.querySelector(`li:nth-child(${i}) .toggle`).click(); + for (let i = 1; i <= numberOfItemsToAdd; i++) page.querySelector(`li:nth-child(${i}) .toggle`).click(); }), new BenchmarkTestStep("DeletingAllItems", (page) => { - for (let i = numberOfItemsToAdd - 1; i >= 0; i--) - page.querySelector(".destroy").click(); + for (let i = numberOfItemsToAdd - 1; i >= 0; i--) page.querySelector(".destroy").click(); }), ], }); @@ -689,13 +651,11 @@ Suites.push({ }), new BenchmarkTestStep("CompletingAllItems", (page) => { const checkboxes = page.querySelectorAll(".toggle"); - for (let i = 0; i < numberOfItemsToAdd; i++) - checkboxes[i].click(); + for (let i = 0; i < numberOfItemsToAdd; i++) checkboxes[i].click(); }), new BenchmarkTestStep("DeletingAllItems", (page) => { const deleteButtons = page.querySelectorAll(".destroy"); - for (let i = numberOfItemsToAdd - 1; i >= 0; i--) - deleteButtons[i].click(); + for (let i = numberOfItemsToAdd - 1; i >= 0; i--) deleteButtons[i].click(); }), ], }); @@ -718,13 +678,11 @@ Suites.push({ }), new BenchmarkTestStep("CompletingAllItems", (page) => { const checkboxes = page.querySelectorAll(".toggle"); - for (let i = 0; i < numberOfItemsToAdd; i++) - checkboxes[i].click(); + for (let i = 0; i < numberOfItemsToAdd; i++) checkboxes[i].click(); }), new BenchmarkTestStep("DeletingAllItems", (page) => { const deleteButtons = page.querySelectorAll(".destroy"); - for (let i = numberOfItemsToAdd - 1; i >= 0; i--) - deleteButtons[i].click(); + for (let i = numberOfItemsToAdd - 1; i >= 0; i--) deleteButtons[i].click(); }), ], }); @@ -748,13 +706,11 @@ Suites.push({ }), new BenchmarkTestStep("CompletingAllItems", (page) => { const checkboxes = page.querySelectorAll(".toggle"); - for (let i = 0; i < numberOfItemsToAdd; i++) - checkboxes[i].click(); + for (let i = 0; i < numberOfItemsToAdd; i++) checkboxes[i].click(); }), new BenchmarkTestStep("DeletingAllItems", (page) => { const deleteButtons = page.querySelectorAll(".destroy"); - for (let i = numberOfItemsToAdd - 1; i >= 0; i--) - deleteButtons[i].click(); + for (let i = numberOfItemsToAdd - 1; i >= 0; i--) deleteButtons[i].click(); }), ], }); @@ -777,13 +733,11 @@ Suites.push({ }), new BenchmarkTestStep("CompletingAllItems", (page) => { const checkboxes = page.querySelectorAll(".toggle"); - for (let i = 0; i < numberOfItemsToAdd; i++) - checkboxes[i].click(); + for (let i = 0; i < numberOfItemsToAdd; i++) checkboxes[i].click(); }), new BenchmarkTestStep("DeletingAllItems", (page) => { const deleteButtons = page.querySelectorAll(".destroy"); - for (let i = numberOfItemsToAdd - 1; i >= 0; i--) - deleteButtons[i].click(); + for (let i = numberOfItemsToAdd - 1; i >= 0; i--) deleteButtons[i].click(); }), ], }); @@ -1050,8 +1004,7 @@ Suites.push({ const coords = (i) => ({ clientX: x + i * 10, clientY: y + i * 2, bubbles: true, cancelable: true }); for (let i = 0; i < 5; i++) { cursor.dispatchEvent("mousedown", coords(0), MouseEvent); - for (let j = 0; j < 10; j++) - cursor.dispatchEvent("mousemove", coords(j), MouseEvent); + for (let j = 0; j < 10; j++) cursor.dispatchEvent("mousemove", coords(j), MouseEvent); cursor.dispatchEvent("mouseup", coords(10), MouseEvent); } }), @@ -1066,8 +1019,7 @@ Suites.push({ bubbles: true, cancelable: true, }; - for (let i = 0; i < 15; i++) - cursor.dispatchEvent("wheel", event, WheelEvent); + for (let i = 0; i < 15; i++) cursor.dispatchEvent("wheel", event, WheelEvent); }), ], }); @@ -1115,14 +1067,10 @@ Suites.push({ Object.freeze(Suites); Suites.forEach((suite) => { - if (!suite.tags) - suite.tags = []; - if (suite.url.startsWith("experimental/")) - suite.tags.unshift("all", "experimental"); - else if (suite.disabled) - suite.tags.unshift("all"); - else - suite.tags.unshift("all", "default"); + if (!suite.tags) suite.tags = []; + if (suite.url.startsWith("experimental/")) suite.tags.unshift("all", "experimental"); + else if (suite.disabled) suite.tags.unshift("all"); + else suite.tags.unshift("all", "default"); Object.freeze(suite.tags); Object.freeze(suite.steps); }); diff --git a/resources/todomvc/architecture-examples/angular/src/app/todo-header/todo-header.component.ts b/resources/todomvc/architecture-examples/angular/src/app/todo-header/todo-header.component.ts index 8d2dbc69e..49a53f781 100644 --- a/resources/todomvc/architecture-examples/angular/src/app/todo-header/todo-header.component.ts +++ b/resources/todomvc/architecture-examples/angular/src/app/todo-header/todo-header.component.ts @@ -14,8 +14,7 @@ export class TodoHeaderComponent { addTodo() { const title = this.titleFormControl.getRawValue()?.trim(); - if (!title) - return; + if (!title) return; this.todosService.addItem(title); this.titleFormControl.setValue(""); diff --git a/resources/todomvc/architecture-examples/angular/src/app/todo-item/todo-item.component.ts b/resources/todomvc/architecture-examples/angular/src/app/todo-item/todo-item.component.ts index b483438f5..e17e3fa75 100644 --- a/resources/todomvc/architecture-examples/angular/src/app/todo-item/todo-item.component.ts +++ b/resources/todomvc/architecture-examples/angular/src/app/todo-item/todo-item.component.ts @@ -47,16 +47,13 @@ export class TodoItemComponent implements AfterViewChecked { updateTodo() { const title = this.titleFormControl.getRawValue()?.trimEnd(); - if (!title) - this.deleteEvent.emit(this.todo); - else - this.todo.title = title; + if (!title) this.deleteEvent.emit(this.todo); + else this.todo.title = title; this.isEditing = false; } ngAfterViewChecked(): void { - if (this.isEditing) - this.inputRef?.nativeElement.focus(); + if (this.isEditing) this.inputRef?.nativeElement.focus(); } } diff --git a/resources/todomvc/architecture-examples/angular/src/app/todos.service.ts b/resources/todomvc/architecture-examples/angular/src/app/todos.service.ts index 02cad243b..7d663de75 100644 --- a/resources/todomvc/architecture-examples/angular/src/app/todos.service.ts +++ b/resources/todomvc/architecture-examples/angular/src/app/todos.service.ts @@ -5,8 +5,7 @@ function uuid() { let uuid = ""; for (let i = 0; i < 32; i++) { const random = (Math.random() * 16) | 0; - if (i === 8 || i === 12 || i === 16 || i === 20) - uuid += "-"; + if (i === 8 || i === 12 || i === 16 || i === 20) uuid += "-"; uuid += (i === 12 ? 4 : i === 16 ? (random & 3) | 8 : random).toString(16); } diff --git a/resources/todomvc/architecture-examples/backbone/scripts/build.js b/resources/todomvc/architecture-examples/backbone/scripts/build.js index ff06b6773..7a0ce32f1 100644 --- a/resources/todomvc/architecture-examples/backbone/scripts/build.js +++ b/resources/todomvc/architecture-examples/backbone/scripts/build.js @@ -29,23 +29,20 @@ const build = async () => { // copy src folder await fs.cp(sourceDirectory, targetDirectory, { recursive: true }, (err) => { - if (err) - console.error(err); + if (err) console.error(err); }); // copy html file await fs.copyFile(path.join(rootDirectory, htmlFile), path.join(targetDirectory, htmlFile)); // copy files to move - for (let i = 0; i < filesToMove.length; i++) - await copy(filesToMove[i], path.join(targetDirectory, path.basename(filesToMove[i]))); + for (let i = 0; i < filesToMove.length; i++) await copy(filesToMove[i], path.join(targetDirectory, path.basename(filesToMove[i]))); // read html file let html = await fs.readFile(path.join(targetDirectory, htmlFile), "utf8"); // remove base paths from files to move - for (let i = 0; i < filesToMove.length; i++) - html = html.replace(filesToMove[i], path.basename(filesToMove[i])); + for (let i = 0; i < filesToMove.length; i++) html = html.replace(filesToMove[i], path.basename(filesToMove[i])); // remove basePath from source directory const basePath = `${path.basename(sourceDirectory)}/`; diff --git a/resources/todomvc/architecture-examples/backbone/src/sync/backbone.sync.js b/resources/todomvc/architecture-examples/backbone/src/sync/backbone.sync.js index 0eaa3ed89..715c46f20 100644 --- a/resources/todomvc/architecture-examples/backbone/src/sync/backbone.sync.js +++ b/resources/todomvc/architecture-examples/backbone/src/sync/backbone.sync.js @@ -31,8 +31,7 @@ Backbone.sync = (function (method, model, options) { size += 1; // if a success callback was provided, execute it. - if (options.success) - options.success(model, model.toJSON(), options); + if (options.success) options.success(model, model.toJSON(), options); // resolve the deferred. deferred.resolve(model); @@ -45,15 +44,13 @@ Backbone.sync = (function (method, model, options) { cache[model.id] = model; // if a success callback was provided, execute it. - if (options.success) - options.success(model, model.toJSON(), options); + if (options.success) options.success(model, model.toJSON(), options); deferred.resolve(model); // if this model doesn't exist yet, we can't update it } else { - if (options.error) - options.error(model, "Model not found"); + if (options.error) options.error(model, "Model not found"); deferred.reject(model); } @@ -62,14 +59,12 @@ Backbone.sync = (function (method, model, options) { // as long as it exists if (cache[model.id]) { // if a success callback was provided, execute it. - if (options.success) - options.success(model, cache[model.id].toJSON(), options); + if (options.success) options.success(model, cache[model.id].toJSON(), options); // resolve deferred.resolve(model); } else { - if (options.error) - options.error(model, "Model not found"); + if (options.error) options.error(model, "Model not found"); deferred.reject(model); } @@ -83,16 +78,14 @@ Backbone.sync = (function (method, model, options) { // and trigger the success callback. Note we're passing an // empty object as the second argument, because a deletion // would result in an empty return from the server. - if (options.success) - options.success(model, {}, options); + if (options.success) options.success(model, {}, options); // resolve the deferred deferred.resolve(model); // otherwise, error that the model doesn't exist. } else { - if (options.error) - options.error(model, "Model not found"); + if (options.error) options.error(model, "Model not found"); deferred.reject(model); } } diff --git a/resources/todomvc/architecture-examples/backbone/src/views/todo-view.js b/resources/todomvc/architecture-examples/backbone/src/views/todo-view.js index 801060075..c37f60f9d 100644 --- a/resources/todomvc/architecture-examples/backbone/src/views/todo-view.js +++ b/resources/todomvc/architecture-examples/backbone/src/views/todo-view.js @@ -45,8 +45,7 @@ var app = app || {}; // `id` change. It's known Backbone LocalStorage bug, therefore // we've to create a workaround. // https://github.com/tastejs/todomvc/issues/469 - if (this.model.changed.id !== undefined) - return null; + if (this.model.changed.id !== undefined) return null; this.$el.html(this.template(this.model.toJSON())); this.$el.toggleClass("completed", this.model.get("completed")); @@ -85,21 +84,17 @@ var app = app || {}; // longer being edited. Relying on the CSS class here has the // benefit of us not having to maintain state in the DOM and the // JavaScript logic. - if (!this.$el.hasClass("editing")) - return; + if (!this.$el.hasClass("editing")) return; - if (trimmedValue) - this.model.save({ title: trimmedValue }); - else - this.clear(); + if (trimmedValue) this.model.save({ title: trimmedValue }); + else this.clear(); this.$el.removeClass("editing"); }, // If you hit `enter`, we're through editing the item. updateOnEnter: function (e) { - if (e.which === ENTER_KEY) - this.close(); + if (e.which === ENTER_KEY) this.close(); }, // If you're pressing `escape` we revert your change by simply leaving diff --git a/resources/todomvc/architecture-examples/lit/src/lib/todo-app.ts b/resources/todomvc/architecture-examples/lit/src/lib/todo-app.ts index 36a50f75f..bc066b285 100644 --- a/resources/todomvc/architecture-examples/lit/src/lib/todo-app.ts +++ b/resources/todomvc/architecture-examples/lit/src/lib/todo-app.ts @@ -86,8 +86,8 @@ export class TodoApp extends LitElement {
`; diff --git a/resources/todomvc/architecture-examples/lit/src/lib/todo-footer.ts b/resources/todomvc/architecture-examples/lit/src/lib/todo-footer.ts index db8c243a7..7245673cf 100644 --- a/resources/todomvc/architecture-examples/lit/src/lib/todo-footer.ts +++ b/resources/todomvc/architecture-examples/lit/src/lib/todo-footer.ts @@ -85,11 +85,10 @@ export class TodoFooter extends LitElement { @updateOnEvent("change") @property({ attribute: false }) - todoList?: Todos; + todoList?: Todos; override render() { - if (this.todoList === undefined || this.todoList.all.length === 0) - return nothing; + if (this.todoList === undefined || this.todoList.all.length === 0) return nothing; const allFilter = filterLink({ text: "All", diff --git a/resources/todomvc/architecture-examples/lit/src/lib/todo-form.ts b/resources/todomvc/architecture-examples/lit/src/lib/todo-form.ts index cd661fda9..eeef32359 100644 --- a/resources/todomvc/architecture-examples/lit/src/lib/todo-form.ts +++ b/resources/todomvc/architecture-examples/lit/src/lib/todo-form.ts @@ -36,7 +36,7 @@ export class TodoForm extends LitElement { @updateOnEvent("change") @property({ attribute: false }) - todoList?: Todos; + todoList?: Todos; override render() { return html``; @@ -46,15 +46,13 @@ export class TodoForm extends LitElement { #onChange() { const { value } = this.newTodoInput; - if (value.length > 0) - this.dispatchEvent(new AddTodoEvent(value)); + if (value.length > 0) this.dispatchEvent(new AddTodoEvent(value)); this.newTodoInput.value = ""; } #onKeydown(e: KeyboardEvent) { - if (e.key === "Enter") - this.#onChange(); + if (e.key === "Enter") this.#onChange(); } } diff --git a/resources/todomvc/architecture-examples/lit/src/lib/todo-item.ts b/resources/todomvc/architecture-examples/lit/src/lib/todo-item.ts index ee3a0395a..2081de86a 100644 --- a/resources/todomvc/architecture-examples/lit/src/lib/todo-item.ts +++ b/resources/todomvc/architecture-examples/lit/src/lib/todo-item.ts @@ -139,16 +139,16 @@ export class TodoItem extends LitElement { ]; @property() - todoId = ""; + todoId = ""; @property() - text = ""; + text = ""; @property({ type: Boolean }) - completed = false; + completed = false; @state() - isEditing: boolean = false; + isEditing: boolean = false; override render() { const itemClassList = { @@ -189,8 +189,7 @@ export class TodoItem extends LitElement { } #captureEscape(e: KeyboardEvent) { - if (e.key === "escape") - this.#abortEdit(e); + if (e.key === "escape") this.#abortEdit(e); } #abortEdit(e: Event) { diff --git a/resources/todomvc/architecture-examples/lit/src/lib/todo-list.ts b/resources/todomvc/architecture-examples/lit/src/lib/todo-list.ts index 3be86c024..78921821a 100644 --- a/resources/todomvc/architecture-examples/lit/src/lib/todo-list.ts +++ b/resources/todomvc/architecture-examples/lit/src/lib/todo-list.ts @@ -88,22 +88,22 @@ export class TodoList extends LitElement { @updateOnEvent("change") @property({ attribute: false }) - todoList?: Todos; + todoList?: Todos; override render() { return html` ${(this.todoList?.all.length ?? 0) > 0 - ? html` + ? html` ` - : nothing} + : nothing}
    ${repeat( - this.todoList?.filtered() ?? [], - (todo) => todo.id, - (todo, index) => html`` - )} + this.todoList?.filtered() ?? [], + (todo) => todo.id, + (todo, index) => html`` + )}
`; } diff --git a/resources/todomvc/architecture-examples/lit/src/lib/todos.ts b/resources/todomvc/architecture-examples/lit/src/lib/todos.ts index f2d02ca96..20a8f1efe 100644 --- a/resources/todomvc/architecture-examples/lit/src/lib/todos.ts +++ b/resources/todomvc/architecture-examples/lit/src/lib/todos.ts @@ -122,8 +122,7 @@ export class Todos extends EventTarget { update(edit: TodoEdit) { const todo = this.#todos.find((todo) => todo.id === edit.id); - if (todo === undefined) - return; + if (todo === undefined) return; Object.assign(todo, edit); this.#notifyChange(); @@ -131,8 +130,7 @@ export class Todos extends EventTarget { toggle(id: string) { const todo = this.#todos.find((todo) => todo.id === id); - if (todo === undefined) - return; + if (todo === undefined) return; todo.completed = !todo.completed; this.#notifyChange(); @@ -171,8 +169,7 @@ export class Todos extends EventTarget { #filterFromUrl() { let filter = /#\/(.*)/.exec(window.location.hash)?.[1]; - if (isTodoFilter(filter)) - return filter; + if (isTodoFilter(filter)) return filter; return "all"; } diff --git a/resources/todomvc/architecture-examples/lit/src/lib/utils.ts b/resources/todomvc/architecture-examples/lit/src/lib/utils.ts index 16a753cbf..5775f8494 100644 --- a/resources/todomvc/architecture-examples/lit/src/lib/utils.ts +++ b/resources/todomvc/architecture-examples/lit/src/lib/utils.ts @@ -18,7 +18,7 @@ export const updateOnEvent = (eventName: string) => (target: ListenerCarryingEle const newDescriptor = { ...descriptor, set(this: ListenerCarryingElement, v: EventTarget) { - const listener = this.__updateOnEventListener ??= () => this.requestUpdate(); + const listener = (this.__updateOnEventListener ??= () => this.requestUpdate()); const oldValue = get!.call(this); oldValue?.removeEventListener?.(eventName, listener); v?.addEventListener?.(eventName, listener); diff --git a/resources/todomvc/architecture-examples/preact/src/app/app.js b/resources/todomvc/architecture-examples/preact/src/app/app.js index a46a642f4..7c353bcf4 100644 --- a/resources/todomvc/architecture-examples/preact/src/app/app.js +++ b/resources/todomvc/architecture-examples/preact/src/app/app.js @@ -12,8 +12,7 @@ const getRoute = () => { .split("/") .pop(); - if (!FILTERS[route]) - route = "all"; + if (!FILTERS[route]) route = "all"; return route; }; @@ -64,12 +63,12 @@ export default function App() { return ( <> - {model.getTodos().length > 0 - ? <> + {model.getTodos().length > 0 ? ( + <> - : null} + ) : null} ); } diff --git a/resources/todomvc/architecture-examples/preact/src/app/footer.js b/resources/todomvc/architecture-examples/preact/src/app/footer.js index 14fdd96bd..90eb10caa 100644 --- a/resources/todomvc/architecture-examples/preact/src/app/footer.js +++ b/resources/todomvc/architecture-examples/preact/src/app/footer.js @@ -25,11 +25,11 @@ export default function TodoFooter({ todos, route, onClearCompleted }) { - {completedTodoCount > 0 - && - } + )} ); } diff --git a/resources/todomvc/architecture-examples/preact/src/app/item.js b/resources/todomvc/architecture-examples/preact/src/app/item.js index 26fe09acb..c8c2ffa1f 100644 --- a/resources/todomvc/architecture-examples/preact/src/app/item.js +++ b/resources/todomvc/architecture-examples/preact/src/app/item.js @@ -27,10 +27,8 @@ export default function TodoItem({ onSave, onRemove, onToggle, todo, index }) { } function handleKeyDown(e) { - if (e.key === "Escape") - setEditing(false); - else if (e.key === "Enter") - handleSubmit(e); + if (e.key === "Escape") setEditing(false); + else if (e.key === "Enter") handleSubmit(e); } function handleDoubleClick() { @@ -53,14 +51,14 @@ export default function TodoItem({ onSave, onRemove, onToggle, todo, index }) {
- {editing - ?
+ {editing ? ( +
- : null} + ) : null} ); } diff --git a/resources/todomvc/architecture-examples/preact/src/app/main.js b/resources/todomvc/architecture-examples/preact/src/app/main.js index 88ee891b7..8271a2f2d 100644 --- a/resources/todomvc/architecture-examples/preact/src/app/main.js +++ b/resources/todomvc/architecture-examples/preact/src/app/main.js @@ -16,9 +16,9 @@ export default function TodoMain({ onChange, onToggle, onRemove, onSave, todos,
    - {visibleTodos.map((todo, index) => + {visibleTodos.map((todo, index) => ( - )} + ))}
); diff --git a/resources/todomvc/architecture-examples/preact/src/app/model.js b/resources/todomvc/architecture-examples/preact/src/app/model.js index 07cb3312c..8517a11ad 100644 --- a/resources/todomvc/architecture-examples/preact/src/app/model.js +++ b/resources/todomvc/architecture-examples/preact/src/app/model.js @@ -58,7 +58,7 @@ export default function TodoModel(sub) { } function toggleItem(todoToToggle) { - todos = todos.map((todo) => todo !== todoToToggle ? todo : { ...todo, completed: !todo.completed }); + todos = todos.map((todo) => (todo !== todoToToggle ? todo : { ...todo, completed: !todo.completed })); inform(); } @@ -68,7 +68,7 @@ export default function TodoModel(sub) { } function updateItem(todoToSave, title) { - todos = todos.map((todo) => todo !== todoToSave ? todo : { ...todo, title }); + todos = todos.map((todo) => (todo !== todoToSave ? todo : { ...todo, title })); inform(); } diff --git a/resources/todomvc/architecture-examples/react-redux/src/components/header.jsx b/resources/todomvc/architecture-examples/react-redux/src/components/header.jsx index 8787856ce..9c9cca4eb 100644 --- a/resources/todomvc/architecture-examples/react-redux/src/components/header.jsx +++ b/resources/todomvc/architecture-examples/react-redux/src/components/header.jsx @@ -8,8 +8,7 @@ export default class Header extends Component { }; handleSave = (text) => { - if (text.length !== 0) - this.props.addTodo(text); + if (text.length !== 0) this.props.addTodo(text); }; render() { diff --git a/resources/todomvc/architecture-examples/react-redux/src/components/item.jsx b/resources/todomvc/architecture-examples/react-redux/src/components/item.jsx index ee2af7903..214da4442 100644 --- a/resources/todomvc/architecture-examples/react-redux/src/components/item.jsx +++ b/resources/todomvc/architecture-examples/react-redux/src/components/item.jsx @@ -21,10 +21,8 @@ export default class Item extends PureComponent { }; handleSave = (id, text) => { - if (text.length === 0) - this.props.deleteTodo(id); - else - this.props.editTodo(id, text); + if (text.length === 0) this.props.deleteTodo(id); + else this.props.editTodo(id, text); this.setState({ editing: false }); }; diff --git a/resources/todomvc/architecture-examples/react-redux/src/components/main.jsx b/resources/todomvc/architecture-examples/react-redux/src/components/main.jsx index 929ef3f02..3865db704 100644 --- a/resources/todomvc/architecture-examples/react-redux/src/components/main.jsx +++ b/resources/todomvc/architecture-examples/react-redux/src/components/main.jsx @@ -20,8 +20,7 @@ export default class Main extends Component { render() { const { todos, editTodo, deleteTodo, toggleTodo, toggleAll, clearCompleted, location, visibleTodos, completedCount, activeCount } = this.props; - if (todos.length === 0) - return null; + if (todos.length === 0) return null; return (
diff --git a/resources/todomvc/architecture-examples/react-redux/src/components/text-input.jsx b/resources/todomvc/architecture-examples/react-redux/src/components/text-input.jsx index d4f145cb9..ff350cd81 100644 --- a/resources/todomvc/architecture-examples/react-redux/src/components/text-input.jsx +++ b/resources/todomvc/architecture-examples/react-redux/src/components/text-input.jsx @@ -19,8 +19,7 @@ export default class TextInput extends Component { const text = e.target.value.trim(); if (e.key === "Enter") { this.props.onSave(text); - if (this.props.newTodo) - this.setState({ text: "" }); + if (this.props.newTodo) this.setState({ text: "" }); } }; @@ -31,8 +30,7 @@ export default class TextInput extends Component { handleBlur = (e) => { // If this input is used in the Header, call onSave to create a new todo. - if (!this.props.newTodo) - this.props.onSave(e.target.value); + if (!this.props.newTodo) this.props.onSave(e.target.value); }; render() { diff --git a/resources/todomvc/architecture-examples/react-redux/src/reducers/todos.js b/resources/todomvc/architecture-examples/react-redux/src/reducers/todos.js index 6ab7e79f5..669d33075 100644 --- a/resources/todomvc/architecture-examples/react-redux/src/reducers/todos.js +++ b/resources/todomvc/architecture-examples/react-redux/src/reducers/todos.js @@ -5,14 +5,11 @@ function uuid() { let uuid = ""; for (let i = 0; i < 32; i++) { const random = (Math.random() * 16) | 0; - if (i === 8 || i === 12 || i === 16 || i === 20) - uuid += "-"; + if (i === 8 || i === 12 || i === 16 || i === 20) uuid += "-"; let currentNumber = random; - if (i === 12) - currentNumber = 4; - else if (i === 16) - currentNumber = 8 | (random & 3); + if (i === 12) currentNumber = 4; + else if (i === 16) currentNumber = 8 | (random & 3); uuid += currentNumber.toString(16); } return uuid; diff --git a/resources/todomvc/architecture-examples/react/src/todo/components/input.jsx b/resources/todomvc/architecture-examples/react/src/todo/components/input.jsx index a386c58c3..dd8583d1e 100644 --- a/resources/todomvc/architecture-examples/react/src/todo/components/input.jsx +++ b/resources/todomvc/architecture-examples/react/src/todo/components/input.jsx @@ -19,8 +19,7 @@ const hasValidMin = (value, min) => { export function Input({ onSubmit, placeholder, label, defaultValue, onBlur }) { const handleBlur = useCallback(() => { - if (onBlur) - onBlur(); + if (onBlur) onBlur(); }, [onBlur]); const handleKeyDown = useCallback( @@ -28,8 +27,7 @@ export function Input({ onSubmit, placeholder, label, defaultValue, onBlur }) { if (e.key === "Enter") { const value = e.target.value.trim(); - if (!hasValidMin(value, 2)) - return; + if (!hasValidMin(value, 2)) return; onSubmit(sanitize(value)); e.target.value = ""; diff --git a/resources/todomvc/architecture-examples/react/src/todo/components/item.jsx b/resources/todomvc/architecture-examples/react/src/todo/components/item.jsx index fdd468364..bc997dd79 100644 --- a/resources/todomvc/architecture-examples/react/src/todo/components/item.jsx +++ b/resources/todomvc/architecture-examples/react/src/todo/components/item.jsx @@ -21,10 +21,8 @@ export const Item = memo(function Item({ todo, dispatch, index }) { const handleUpdate = useCallback( (title) => { - if (title.length === 0) - removeItem(id); - else - updateItem(id, title); + if (title.length === 0) removeItem(id); + else updateItem(id, title); setIsWritable(false); }, diff --git a/resources/todomvc/architecture-examples/react/src/todo/components/main.jsx b/resources/todomvc/architecture-examples/react/src/todo/components/main.jsx index 22566eb87..386a05d3d 100644 --- a/resources/todomvc/architecture-examples/react/src/todo/components/main.jsx +++ b/resources/todomvc/architecture-examples/react/src/todo/components/main.jsx @@ -10,11 +10,9 @@ export function Main({ todos, dispatch }) { const visibleTodos = useMemo( () => todos.filter((todo) => { - if (route === "/active") - return !todo.completed; + if (route === "/active") return !todo.completed; - if (route === "/completed") - return todo.completed; + if (route === "/completed") return todo.completed; return todo; }), diff --git a/resources/todomvc/big-dom-generator/src/components/popovers/analytics.jsx b/resources/todomvc/big-dom-generator/src/components/popovers/analytics.jsx index 84ded2091..e871d2f05 100644 --- a/resources/todomvc/big-dom-generator/src/components/popovers/analytics.jsx +++ b/resources/todomvc/big-dom-generator/src/components/popovers/analytics.jsx @@ -16,8 +16,7 @@ const ProgressBar = ({ teamNumber, value, index }) => { export const AnalyticsPopOver = ({ className }) => { const children = []; const numProgressBars = 5; - for (let i = 0; i < numProgressBars; i++) - children.push(); + for (let i = 0; i < numProgressBars; i++) children.push(); return {children}; }; diff --git a/resources/todomvc/big-dom-generator/src/components/popovers/date-picker.jsx b/resources/todomvc/big-dom-generator/src/components/popovers/date-picker.jsx index 6d8792969..7d482c43a 100644 --- a/resources/todomvc/big-dom-generator/src/components/popovers/date-picker.jsx +++ b/resources/todomvc/big-dom-generator/src/components/popovers/date-picker.jsx @@ -7,13 +7,13 @@ import AddIcon from "./../../assets/Smock_Add_18_N.svg"; const DaysOfTheWeekHeadings = () => { const daysOfTheWeek = { Sunday: "S", Monday: "M", Tuesday: "T", Wednesday: "W", Thursday: "T", Friday: "F", Saturday: "S" }; - return Object.entries(daysOfTheWeek).map(([key, value]) => + return Object.entries(daysOfTheWeek).map(([key, value]) => ( {value} - ); + )); }; const CalendarRow = ({ weekStart }) => { diff --git a/resources/todomvc/big-dom-generator/src/components/popovers/filter.jsx b/resources/todomvc/big-dom-generator/src/components/popovers/filter.jsx index 1c7f38005..fd0576c17 100644 --- a/resources/todomvc/big-dom-generator/src/components/popovers/filter.jsx +++ b/resources/todomvc/big-dom-generator/src/components/popovers/filter.jsx @@ -32,11 +32,11 @@ const TagGroup = () => { return (
- {tags.map((tag, index) => + {tags.map((tag, index) => (
{tag.label}
- )} + ))}
); }; diff --git a/resources/todomvc/big-dom-generator/src/components/popovers/notifications.jsx b/resources/todomvc/big-dom-generator/src/components/popovers/notifications.jsx index bc2c26a81..db6e89c69 100644 --- a/resources/todomvc/big-dom-generator/src/components/popovers/notifications.jsx +++ b/resources/todomvc/big-dom-generator/src/components/popovers/notifications.jsx @@ -36,7 +36,7 @@ export const NotificationsPopOver = () => { }, ]; - const listItems = notifications.map((notification, index) => + const listItems = notifications.map((notification, index) => (
  • @@ -47,7 +47,7 @@ export const NotificationsPopOver = () => {
  • - ); + )); return (
    diff --git a/resources/todomvc/big-dom-generator/src/components/popovers/popover.jsx b/resources/todomvc/big-dom-generator/src/components/popovers/popover.jsx index 637707539..deafa9c92 100644 --- a/resources/todomvc/big-dom-generator/src/components/popovers/popover.jsx +++ b/resources/todomvc/big-dom-generator/src/components/popovers/popover.jsx @@ -11,11 +11,11 @@ export const PopOver = ({ children, className, startRight }) => { }; export const VerticalPopOver = ({ children, className, startRight }) => { - const actionItems = Children.toArray(children).map((child, index) => + const actionItems = Children.toArray(children).map((child, index) => (
    {child}
    - ); + )); return (
    {actionItems}
    diff --git a/resources/todomvc/big-dom-generator/src/components/tree-area.jsx b/resources/todomvc/big-dom-generator/src/components/tree-area.jsx index b6287f4cd..8175ed994 100644 --- a/resources/todomvc/big-dom-generator/src/components/tree-area.jsx +++ b/resources/todomvc/big-dom-generator/src/components/tree-area.jsx @@ -17,23 +17,24 @@ const TreeItem = (props) => { return (
  • - {isExpandableItem - ? <> + {isExpandableItem ? ( + <> Sprint
      - {treeNode.children.map((child) => + {treeNode.children.map((child) => ( - )} + ))}
    - : + ) : ( + Todo List - } + )}
  • ); }; diff --git a/resources/todomvc/big-dom-generator/src/tree-generator.js b/resources/todomvc/big-dom-generator/src/tree-generator.js index 4accc5cb6..e585a63cc 100644 --- a/resources/todomvc/big-dom-generator/src/tree-generator.js +++ b/resources/todomvc/big-dom-generator/src/tree-generator.js @@ -5,10 +5,8 @@ const random = new LCG(DEFAULT_SEED_FOR_RANDOM_NUMBER_GENERATOR); // Recursively depth-first computing subTreeWeight. const fillSubtreeWeights = (node, expandableItemWeight, nonExpandableItemWeight) => { - if (node.type === "expandableItem") - node.subTreeWeight = node.children.reduce((acc, child) => acc + fillSubtreeWeights(child, expandableItemWeight, nonExpandableItemWeight), expandableItemWeight); - else - node.subTreeWeight = nonExpandableItemWeight; + if (node.type === "expandableItem") node.subTreeWeight = node.children.reduce((acc, child) => acc + fillSubtreeWeights(child, expandableItemWeight, nonExpandableItemWeight), expandableItemWeight); + else node.subTreeWeight = nonExpandableItemWeight; return node.subTreeWeight; }; @@ -48,8 +46,7 @@ const markDisplayNoneNodes = (node, expandableItemWeight, nonExpandableItemWeigh currentIndex++; } nodeQueue.forEach((node) => { - if (node) - node.isDisplayNone = true; + if (node) node.isDisplayNone = true; }); }; diff --git a/resources/todomvc/todomvc-css/plugins/constructable-css/index.js b/resources/todomvc/todomvc-css/plugins/constructable-css/index.js index db23c4db6..59c2bb3ed 100644 --- a/resources/todomvc/todomvc-css/plugins/constructable-css/index.js +++ b/resources/todomvc/todomvc-css/plugins/constructable-css/index.js @@ -13,8 +13,7 @@ async function create(src, dest) { } function constructableCSS({ src, dest = "dist/", hook = "generateBundle" } = {}) { - if (!src) - throw new Error("src option missing"); + if (!src) throw new Error("src option missing"); return { name: "constructable-css", diff --git a/resources/todomvc/vanilla-examples/javascript-es5/scripts/build.js b/resources/todomvc/vanilla-examples/javascript-es5/scripts/build.js index 046de0e7e..3e276b4e3 100644 --- a/resources/todomvc/vanilla-examples/javascript-es5/scripts/build.js +++ b/resources/todomvc/vanilla-examples/javascript-es5/scripts/build.js @@ -22,16 +22,14 @@ const build = async () => { // copy src folder await fs.cp(sourceDirectory, targetDirectory, { recursive: true }, (err) => { - if (err) - console.error(err); + if (err) console.error(err); }); // copy html file await fs.copyFile(path.join(rootDirectory, htmlFile), path.join(targetDirectory, htmlFile)); // copy files to move - for (let i = 0; i < filesToMove.length; i++) - await copy(filesToMove[i], path.join(targetDirectory, path.basename(filesToMove[i]))); + for (let i = 0; i < filesToMove.length; i++) await copy(filesToMove[i], path.join(targetDirectory, path.basename(filesToMove[i]))); // read html file let html = await fs.readFile(path.join(targetDirectory, htmlFile), "utf8"); diff --git a/resources/todomvc/vanilla-examples/javascript-es5/src/controller.js b/resources/todomvc/vanilla-examples/javascript-es5/src/controller.js index 229b19dde..8886693f0 100644 --- a/resources/todomvc/vanilla-examples/javascript-es5/src/controller.js +++ b/resources/todomvc/vanilla-examples/javascript-es5/src/controller.js @@ -95,8 +95,7 @@ Controller.prototype.addItem = function (title) { var self = this; - if (title.trim() === "") - return; + if (title.trim() === "") return; self.model.create(title, function () { self.view.render("clearNewTodo"); @@ -188,8 +187,7 @@ }); }); - if (!silent) - self._filter(); + if (!silent) self._filter(); }; /** @@ -238,8 +236,7 @@ // If the last active route isn't "All", or we're switching routes, we // re-create the todo item elements, calling: // this.show[All|Active|Completed](); - if (force || this._lastActiveRoute !== "All" || this._lastActiveRoute !== activeRoute) - this[`show${activeRoute}`](); + if (force || this._lastActiveRoute !== "All" || this._lastActiveRoute !== activeRoute) this[`show${activeRoute}`](); this._lastActiveRoute = activeRoute; }; @@ -252,8 +249,7 @@ // items as they are marked complete or incomplete. this._activeRoute = currentPage; - if (currentPage === "") - this._activeRoute = "All"; + if (currentPage === "") this._activeRoute = "All"; this._filter(); diff --git a/resources/todomvc/vanilla-examples/javascript-es5/src/helpers.js b/resources/todomvc/vanilla-examples/javascript-es5/src/helpers.js index de93a88f2..ae7862d4f 100644 --- a/resources/todomvc/vanilla-examples/javascript-es5/src/helpers.js +++ b/resources/todomvc/vanilla-examples/javascript-es5/src/helpers.js @@ -23,8 +23,7 @@ var potentialElements = window.qsa(selector, target); var hasMatch = Array.prototype.indexOf.call(potentialElements, targetElement) >= 0; - if (hasMatch) - handler.call(targetElement, event); + if (hasMatch) handler.call(targetElement, event); } // https://developer.mozilla.org/en-US/docs/Web/Events/blur @@ -36,11 +35,9 @@ // Find the element's parent with the given tag name: // $parent(qs('a'), 'div'); window.$parent = function (element, tagName) { - if (!element.parentNode) - return undefined; + if (!element.parentNode) return undefined; - if (element.parentNode.tagName.toLowerCase() === tagName.toLowerCase()) - return element.parentNode; + if (element.parentNode.tagName.toLowerCase() === tagName.toLowerCase()) return element.parentNode; return window.$parent(element.parentNode, tagName); }; diff --git a/resources/todomvc/vanilla-examples/javascript-es5/src/model.js b/resources/todomvc/vanilla-examples/javascript-es5/src/model.js index 2268fe853..076a0ab37 100644 --- a/resources/todomvc/vanilla-examples/javascript-es5/src/model.js +++ b/resources/todomvc/vanilla-examples/javascript-es5/src/model.js @@ -102,10 +102,8 @@ this.storage.findAll(function (data) { data.forEach(function (todo) { - if (todo.completed) - todos.completed++; - else - todos.active++; + if (todo.completed) todos.completed++; + else todos.active++; todos.total++; }); diff --git a/resources/todomvc/vanilla-examples/javascript-es5/src/store.js b/resources/todomvc/vanilla-examples/javascript-es5/src/store.js index 2493c12aa..1c29c9c66 100644 --- a/resources/todomvc/vanilla-examples/javascript-es5/src/store.js +++ b/resources/todomvc/vanilla-examples/javascript-es5/src/store.js @@ -43,8 +43,7 @@ * }); */ Store.prototype.find = function (query, callback) { - if (!callback) - return; + if (!callback) return; var todos = JSON.parse(MemoryStorage[this._dbName]).todos; @@ -52,8 +51,7 @@ this, todos.filter(function (todo) { for (var q in query) { - if (query[q] !== todo[q]) - return false; + if (query[q] !== todo[q]) return false; } return true; @@ -89,8 +87,7 @@ if (id) { for (var i = 0; i < todos.length; i++) { if (todos[i].id === id) { - for (var key in updateData) - todos[i][key] = updateData[key]; + for (var key in updateData) todos[i][key] = updateData[key]; break; } diff --git a/resources/todomvc/vanilla-examples/javascript-es5/src/template.js b/resources/todomvc/vanilla-examples/javascript-es5/src/template.js index fac7e2099..bc119ee2a 100644 --- a/resources/todomvc/vanilla-examples/javascript-es5/src/template.js +++ b/resources/todomvc/vanilla-examples/javascript-es5/src/template.js @@ -28,14 +28,14 @@ * @constructor */ function Template() { - this.defaultTemplate - = '
  • ' - + '
    ' - + '' - + "" - + '' - + "
    " - + "
  • "; + this.defaultTemplate = + '
  • ' + + '
    ' + + '' + + "" + + '' + + "
    " + + "
  • "; } /** @@ -100,10 +100,8 @@ * @returns {string} String containing the count */ Template.prototype.clearCompletedButton = function (completedTodos) { - if (completedTodos > 0) - return "Clear completed"; - else - return ""; + if (completedTodos > 0) return "Clear completed"; + else return ""; }; // Export to window diff --git a/resources/todomvc/vanilla-examples/javascript-es5/src/view.js b/resources/todomvc/vanilla-examples/javascript-es5/src/view.js index b34323332..3bb603729 100644 --- a/resources/todomvc/vanilla-examples/javascript-es5/src/view.js +++ b/resources/todomvc/vanilla-examples/javascript-es5/src/view.js @@ -31,8 +31,7 @@ View.prototype._removeItem = function (id) { var elem = qs(`[data-id="${id}"]`); - if (elem) - this.$todoList.removeChild(elem); + if (elem) this.$todoList.removeChild(elem); }; View.prototype._clearCompletedButton = function (completedCount, visible) { @@ -48,8 +47,7 @@ View.prototype._elementComplete = function (id, completed) { var listItem = qs(`[data-id="${id}"]`); - if (!listItem) - return; + if (!listItem) return; listItem.className = completed ? "completed" : ""; @@ -60,8 +58,7 @@ View.prototype._editItem = function (id, title) { var listItem = qs(`[data-id="${id}"]`); - if (!listItem) - return; + if (!listItem) return; listItem.className = `${listItem.className} editing`; @@ -76,8 +73,7 @@ View.prototype._editItemDone = function (id, title) { var listItem = qs(`[data-id="${id}"]`); - if (!listItem) - return; + if (!listItem) return; var input = qs("input.edit", listItem); listItem.removeChild(input); diff --git a/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/app.js b/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/app.js index 866753165..7f5dc761e 100644 --- a/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/app.js +++ b/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/app.js @@ -28,8 +28,7 @@ function Todo(name) { /* HOT MODULE SPECIFIC */ if (module.hot) { module.hot.accept(function (err) {}); - if (document.readyState === "complete") - onLoad(); + if (document.readyState === "complete") onLoad(); } window.addEventListener("load", onLoad); diff --git a/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/controller.js b/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/controller.js index 76a2db5b6..e0f6127a8 100644 --- a/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/controller.js +++ b/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/controller.js @@ -54,8 +54,7 @@ class Controller { * object and it'll handle the DOM insertion and saving of the new item. */ addItem(title) { - if (title.trim() === "") - return; + if (title.trim() === "") return; this.model.create(title, () => { this.view.render("clearNewTodo"); @@ -112,8 +111,7 @@ class Controller { */ removeCompletedItems() { this.model.read({ completed: true }, (data) => { - for (let item of data) - this.removeItem(item.id); + for (let item of data) this.removeItem(item.id); }); this._filter(); @@ -133,8 +131,7 @@ class Controller { this.view.render("elementComplete", { id, completed }); }); - if (!silent) - this._filter(); + if (!silent) this._filter(); } /** @@ -143,8 +140,7 @@ class Controller { */ toggleAll(completed) { this.model.read({ completed: !completed }, (data) => { - for (let item of data) - this.toggleComplete(item.id, completed, true); + for (let item of data) this.toggleComplete(item.id, completed, true); }); this._filter(); @@ -181,8 +177,7 @@ class Controller { // If the last active route isn't "All", or we're switching routes, we // re-create the todo item elements, calling: // this.show[All|Active|Completed]() - if (force || this._lastActiveRoute !== "All" || this._lastActiveRoute !== activeRoute) - this[`show${activeRoute}`](); + if (force || this._lastActiveRoute !== "All" || this._lastActiveRoute !== activeRoute) this[`show${activeRoute}`](); this._lastActiveRoute = activeRoute; } @@ -195,8 +190,7 @@ class Controller { // items as they are marked complete or incomplete. this._activeRoute = currentPage; - if (currentPage === "") - this._activeRoute = "All"; + if (currentPage === "") this._activeRoute = "All"; this._filter(); diff --git a/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/helpers.js b/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/helpers.js index c0cb47a64..6a0e5b515 100644 --- a/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/helpers.js +++ b/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/helpers.js @@ -26,19 +26,16 @@ const $delegate = (target, selector, type, handler) => { const potentialElements = qsa(selector, target); const hasMatch = Array.prototype.indexOf.call(potentialElements, targetElement) >= 0; - if (hasMatch) - handler.call(targetElement, event); + if (hasMatch) handler.call(targetElement, event); } }; // Find the element's parent with the given tag name: // $parent(qs('a'), 'div'); const $parent = (element, tagName) => { - if (!element.parentNode) - return undefined; + if (!element.parentNode) return undefined; - if (element.parentNode.tagName.toLowerCase() === tagName.toLowerCase()) - return element.parentNode; + if (element.parentNode.tagName.toLowerCase() === tagName.toLowerCase()) return element.parentNode; return $parent(element.parentNode, tagName); }; @@ -49,8 +46,7 @@ const $parent = (element, tagName) => { // x ~== [1,3] const remove = (array, thing) => { const index = array.indexOf(thing); - if (index === -1) - return array; + if (index === -1) return array; return array.splice(index, 1); }; diff --git a/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/model.js b/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/model.js index b37df66af..c081c4cff 100644 --- a/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/model.js +++ b/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/model.js @@ -89,8 +89,7 @@ class Model { * Returns a count of all todos */ getCount(callback) { - if (!callback) - return; + if (!callback) return; const stats = { active: 0, @@ -100,10 +99,8 @@ class Model { this.storage.findAll((data) => { for (let todo of data) { - if (todo.completed) - stats.completed++; - else - stats.active++; + if (todo.completed) stats.completed++; + else stats.active++; stats.total++; } diff --git a/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/store.js b/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/store.js index 5a07bf255..619c855e0 100644 --- a/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/store.js +++ b/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/store.js @@ -25,8 +25,7 @@ export class Store { memoryStorage[name] = JSON.stringify(data); } - if (callback) - callback(JSON.parse(memoryStorage[name])); + if (callback) callback(JSON.parse(memoryStorage[name])); } /** @@ -43,16 +42,14 @@ export class Store { * }) */ find(query, callback) { - if (!callback) - return; + if (!callback) return; const { todos } = JSON.parse(memoryStorage[this._dbName]); callback( todos.filter((todo) => { for (let q in query) { - if (query[q] !== todo[q]) - return false; + if (query[q] !== todo[q]) return false; } return true; @@ -66,8 +63,7 @@ export class Store { * @param {function} callback The callback to fire upon retrieving data */ findAll(callback) { - if (!callback) - return; + if (!callback) return; callback(JSON.parse(memoryStorage[this._dbName]).todos); } @@ -88,8 +84,7 @@ export class Store { if (id) { for (let i = 0; i < todos.length; i++) { if (todos[i].id === id) { - for (let key in updateData) - todos[i][key] = updateData[key]; + for (let key in updateData) todos[i][key] = updateData[key]; break; } @@ -97,8 +92,7 @@ export class Store { memoryStorage[this._dbName] = JSON.stringify(data); - if (callback) - callback(JSON.parse(memoryStorage[this._dbName]).todos); + if (callback) callback(JSON.parse(memoryStorage[this._dbName]).todos); } else { // Generate an ID updateData.id = uniqueID++; @@ -106,8 +100,7 @@ export class Store { todos.push(updateData); memoryStorage[this._dbName] = JSON.stringify(data); - if (callback) - callback([updateData]); + if (callback) callback([updateData]); } } @@ -130,8 +123,7 @@ export class Store { memoryStorage[this._dbName] = JSON.stringify(data); - if (callback) - callback(JSON.parse(memoryStorage[this._dbName]).todos); + if (callback) callback(JSON.parse(memoryStorage[this._dbName]).todos); } /** @@ -142,8 +134,7 @@ export class Store { drop(callback) { memoryStorage[this._dbName] = JSON.stringify({ todos: [] }); - if (callback) - callback(JSON.parse(memoryStorage[this._dbName]).todos); + if (callback) callback(JSON.parse(memoryStorage[this._dbName]).todos); } } diff --git a/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/template.js b/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/template.js index 7977d5133..0f681a6a9 100644 --- a/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/template.js +++ b/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/template.js @@ -12,7 +12,7 @@ const htmlEscapes = { const reUnescapedHtml = /[&<>"'`]/g; const reHasUnescapedHtml = new RegExp(reUnescapedHtml.source); -const escape = (str) => str && reHasUnescapedHtml.test(str) ? str.replace(reUnescapedHtml, escapeHtmlChar) : str; +const escape = (str) => (str && reHasUnescapedHtml.test(str) ? str.replace(reUnescapedHtml, escapeHtmlChar) : str); const escapeHtmlChar = (chr) => htmlEscapes[chr]; const createTodoItem = ({ id, title, completed, checked, index }) => ` diff --git a/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/view.js b/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/view.js index f5ba496a0..82d347145 100644 --- a/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/view.js +++ b/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/view.js @@ -12,8 +12,7 @@ const _setFilter = (currentPage) => { const _elementComplete = (id, completed) => { const listItem = qs(`[data-id="${id}"]`); - if (!listItem) - return; + if (!listItem) return; listItem.className = completed ? "completed" : ""; @@ -24,8 +23,7 @@ const _elementComplete = (id, completed) => { const _editItem = (id, title) => { const listItem = qs(`[data-id="${id}"]`); - if (!listItem) - return; + if (!listItem) return; listItem.className = `${listItem.className} editing`; @@ -40,8 +38,7 @@ const _editItem = (id, title) => { const _editItemDone = (id, title) => { const listItem = qs(`[data-id="${id}"]`); - if (!listItem) - return; + if (!listItem) return; const input = qs("input.edit", listItem); listItem.removeChild(input); @@ -61,8 +58,7 @@ const _itemId = (element) => { const _removeItem = (id, list) => { const elem = qs(`[data-id="${id}"]`); - if (elem) - list.removeChild(elem); + if (elem) list.removeChild(elem); }; /** @@ -168,8 +164,7 @@ export default class View { } }); $delegate(this.$todoList, "li .edit", "keypress", function (e) { - if (e.keyCode === ENTER_KEY) - e.target.blur(); + if (e.keyCode === ENTER_KEY) e.target.blur(); }); break; case "itemEditCancel": diff --git a/resources/todomvc/vanilla-examples/javascript-web-components/scripts/build.js b/resources/todomvc/vanilla-examples/javascript-web-components/scripts/build.js index d5fa77557..9ebebf888 100644 --- a/resources/todomvc/vanilla-examples/javascript-web-components/scripts/build.js +++ b/resources/todomvc/vanilla-examples/javascript-web-components/scripts/build.js @@ -42,8 +42,7 @@ const copy = async (src, dest) => { }; const copyFilesToMove = async (files) => { - for (let i = 0; i < files.length; i++) - await copy(files[i].src, `${targetDirectory}/${files[i].dest}`); + for (let i = 0; i < files.length; i++) await copy(files[i].src, `${targetDirectory}/${files[i].dest}`); }; const updateImports = async ({ file, src, dest }) => { @@ -61,21 +60,18 @@ const build = async () => { // copy src folder await fs.cp(sourceDirectory, targetDirectory, { recursive: true }, (err) => { - if (err) - console.error(err); + if (err) console.error(err); }); // copy files to Move - for (const key in filesToMove) - copyFilesToMove(filesToMove[key]); + for (const key in filesToMove) copyFilesToMove(filesToMove[key]); // read html file let contents = await fs.readFile(`${rootDirectory}/${htmlFile}`, "utf8"); // remove base paths from files to move const filesToMoveForIndex = filesToMove.index; - for (let i = 0; i < filesToMoveForIndex.length; i++) - contents = contents.replace(filesToMoveForIndex[i].src, filesToMoveForIndex[i].dest); + for (let i = 0; i < filesToMoveForIndex.length; i++) contents = contents.replace(filesToMoveForIndex[i].src, filesToMoveForIndex[i].dest); // remove basePath from source directory const basePath = `${sourceDirectory.split("/")[1]}/`; diff --git a/resources/todomvc/vanilla-examples/javascript-web-components/src/components/todo-app/todo-app.component.js b/resources/todomvc/vanilla-examples/javascript-web-components/src/components/todo-app/todo-app.component.js index 691980f3e..8418c88b0 100644 --- a/resources/todomvc/vanilla-examples/javascript-web-components/src/components/todo-app/todo-app.component.js +++ b/resources/todomvc/vanilla-examples/javascript-web-components/src/components/todo-app/todo-app.component.js @@ -51,8 +51,7 @@ class TodoApp extends HTMLElement { toggleItem(event) { this.#data.forEach((entry) => { - if (entry.id === event.detail.id) - entry.completed = event.detail.completed; + if (entry.id === event.detail.id) entry.completed = event.detail.completed; }); this.update("toggle-item", event.detail.id); @@ -60,8 +59,7 @@ class TodoApp extends HTMLElement { removeItem(event) { this.#data.forEach((entry, index) => { - if (entry.id === event.detail.id) - this.#data.splice(index, 1); + if (entry.id === event.detail.id) this.#data.splice(index, 1); }); this.update("remove-item", event.detail.id); @@ -69,8 +67,7 @@ class TodoApp extends HTMLElement { updateItem(event) { this.#data.forEach((entry) => { - if (entry.id === event.detail.id) - entry.title = event.detail.title; + if (entry.id === event.detail.id) entry.title = event.detail.title; }); this.update("update-item", event.detail.id); diff --git a/resources/todomvc/vanilla-examples/javascript-web-components/src/components/todo-bottombar/todo-bottombar.component.js b/resources/todomvc/vanilla-examples/javascript-web-components/src/components/todo-bottombar/todo-bottombar.component.js index f5b8896c5..0c73cb291 100644 --- a/resources/todomvc/vanilla-examples/javascript-web-components/src/components/todo-bottombar/todo-bottombar.component.js +++ b/resources/todomvc/vanilla-examples/javascript-web-components/src/components/todo-bottombar/todo-bottombar.component.js @@ -27,20 +27,16 @@ class TodoBottombar extends HTMLElement { } updateDisplay() { - if (parseInt(this["total-items"]) !== 0) - this.element.style.display = "block"; - else - this.element.style.display = "none"; + if (parseInt(this["total-items"]) !== 0) this.element.style.display = "block"; + else this.element.style.display = "none"; this.todoStatus.textContent = `${this["active-items"]} ${this["active-items"] === "1" ? "item" : "items"} left!`; } updateRoute(route) { this.filterLinks.forEach((link) => { - if (link.dataset.route === route) - link.classList.add("selected"); - else - link.classList.remove("selected"); + if (link.dataset.route === route) link.classList.add("selected"); + else link.classList.remove("selected"); }); } @@ -57,12 +53,10 @@ class TodoBottombar extends HTMLElement { } attributeChangedCallback(property, oldValue, newValue) { - if (oldValue === newValue) - return; + if (oldValue === newValue) return; this[property] = newValue; - if (this.isConnected) - this.updateDisplay(); + if (this.isConnected) this.updateDisplay(); } connectedCallback() { diff --git a/resources/todomvc/vanilla-examples/javascript-web-components/src/components/todo-item/todo-item.component.js b/resources/todomvc/vanilla-examples/javascript-web-components/src/components/todo-item/todo-item.component.js index 7a310bf82..13c255c18 100644 --- a/resources/todomvc/vanilla-examples/javascript-web-components/src/components/todo-item/todo-item.component.js +++ b/resources/todomvc/vanilla-examples/javascript-web-components/src/components/todo-item/todo-item.component.js @@ -55,8 +55,7 @@ class TodoItem extends HTMLElement { args.forEach((argument) => { switch (argument) { case "itemid": - if (this.itemid !== undefined) - this.item.id = `todo-item-${this.itemid}`; + if (this.itemid !== undefined) this.item.id = `todo-item-${this.itemid}`; break; case "itemtitle": if (this.itemtitle !== undefined) { @@ -147,12 +146,10 @@ class TodoItem extends HTMLElement { } attributeChangedCallback(property, oldValue, newValue) { - if (oldValue === newValue) - return; + if (oldValue === newValue) return; this[property] = newValue; - if (this.isConnected) - this.update(property); + if (this.isConnected) this.update(property); } connectedCallback() { diff --git a/resources/todomvc/vanilla-examples/javascript-web-components/src/components/todo-list/todo-list.component.js b/resources/todomvc/vanilla-examples/javascript-web-components/src/components/todo-list/todo-list.component.js index 766f4124b..366169de3 100644 --- a/resources/todomvc/vanilla-examples/javascript-web-components/src/components/todo-list/todo-list.component.js +++ b/resources/todomvc/vanilla-examples/javascript-web-components/src/components/todo-list/todo-list.component.js @@ -52,8 +52,7 @@ class TodoList extends HTMLElement { removeCompletedItems() { this.#elements = this.#elements.filter((element) => { - if (element.itemcompleted === "true") - element.removeItem(); + if (element.itemcompleted === "true") element.removeItem(); return element.itemcompleted === "false"; }); @@ -61,18 +60,14 @@ class TodoList extends HTMLElement { toggleItems(completed) { this.#elements.forEach((element) => { - if (completed && element.itemcompleted === "false") - element.toggleInput.click(); - else if (!completed && element.itemcompleted === "true") - element.toggleInput.click(); + if (completed && element.itemcompleted === "false") element.toggleInput.click(); + else if (!completed && element.itemcompleted === "true") element.toggleInput.click(); }); } updateStyles() { - if (parseInt(this["total-items"]) !== 0) - this.listNode.style.display = "block"; - else - this.listNode.style.display = "none"; + if (parseInt(this["total-items"]) !== 0) this.listNode.style.display = "block"; + else this.listNode.style.display = "none"; } updateView(element) { @@ -96,8 +91,7 @@ class TodoList extends HTMLElement { case "toggle-item": case "add-item": this.#elements.forEach((element) => { - if (element.itemid === id) - this.updateView(element); + if (element.itemid === id) this.updateView(element); }); break; case "remove-item": @@ -112,11 +106,9 @@ class TodoList extends HTMLElement { } attributeChangedCallback(property, oldValue, newValue) { - if (oldValue === newValue) - return; + if (oldValue === newValue) return; this[property] = newValue; - if (this.isConnected) - this.updateStyles(); + if (this.isConnected) this.updateStyles(); } connectedCallback() { diff --git a/resources/todomvc/vanilla-examples/javascript-web-components/src/components/todo-topbar/todo-topbar.component.js b/resources/todomvc/vanilla-examples/javascript-web-components/src/components/todo-topbar/todo-topbar.component.js index 973fb0614..5abc024c9 100644 --- a/resources/todomvc/vanilla-examples/javascript-web-components/src/components/todo-topbar/todo-topbar.component.js +++ b/resources/todomvc/vanilla-examples/javascript-web-components/src/components/todo-topbar/todo-topbar.component.js @@ -41,8 +41,7 @@ class TodoTopbar extends HTMLElement { } addItem(event) { - if (!event.target.value.length) - return; + if (!event.target.value.length) return; this.dispatchEvent( new CustomEvent("add-item", { @@ -96,12 +95,10 @@ class TodoTopbar extends HTMLElement { } attributeChangedCallback(property, oldValue, newValue) { - if (oldValue === newValue) - return; + if (oldValue === newValue) return; this[property] = newValue; - if (this.isConnected) - this.updateDisplay(); + if (this.isConnected) this.updateDisplay(); } connectedCallback() { diff --git a/resources/todomvc/vanilla-examples/javascript-web-components/src/hooks/useDoubleClick.js b/resources/todomvc/vanilla-examples/javascript-web-components/src/hooks/useDoubleClick.js index a1fe952fe..94e4a7d6a 100644 --- a/resources/todomvc/vanilla-examples/javascript-web-components/src/hooks/useDoubleClick.js +++ b/resources/todomvc/vanilla-examples/javascript-web-components/src/hooks/useDoubleClick.js @@ -11,8 +11,7 @@ export function useDoubleClick(fn, delay) { return function (...args) { const now = new Date().getTime(); const difference = now - last; - if (difference < delay && difference > 0) - fn.apply(this, args); + if (difference < delay && difference > 0) fn.apply(this, args); last = now; }; diff --git a/resources/todomvc/vanilla-examples/javascript-web-components/src/hooks/useKeyListener.js b/resources/todomvc/vanilla-examples/javascript-web-components/src/hooks/useKeyListener.js index 453747d54..30196c960 100644 --- a/resources/todomvc/vanilla-examples/javascript-web-components/src/hooks/useKeyListener.js +++ b/resources/todomvc/vanilla-examples/javascript-web-components/src/hooks/useKeyListener.js @@ -3,8 +3,7 @@ export function useKeyListener(props) { function handleEvent(event) { Object.keys(callbacks).forEach((key) => { - if (event.key === key) - callbacks[key](event); + if (event.key === key) callbacks[key](event); }); } diff --git a/resources/todomvc/vanilla-examples/javascript-web-components/src/hooks/useRouter.js b/resources/todomvc/vanilla-examples/javascript-web-components/src/hooks/useRouter.js index ab1ab618a..5b02573ec 100644 --- a/resources/todomvc/vanilla-examples/javascript-web-components/src/hooks/useRouter.js +++ b/resources/todomvc/vanilla-examples/javascript-web-components/src/hooks/useRouter.js @@ -14,8 +14,7 @@ export const useRouter = (callback) => { const handleChange = () => { current = document.location.hash; /* istanbul ignore else */ - if (onChange) - onChange(document.location.hash); + if (onChange) onChange(document.location.hash); }; /** diff --git a/tests/benchmark-runner-tests.mjs b/tests/benchmark-runner-tests.mjs index 449ceb266..8e127918d 100644 --- a/tests/benchmark-runner-tests.mjs +++ b/tests/benchmark-runner-tests.mjs @@ -119,8 +119,7 @@ describe("BenchmarkRunner", () => { _loadFrameStub = stub(SuiteRunner.prototype, "_loadFrame").callsFake(async () => null); _appendFrameStub = stub(runner, "_appendFrame").callsFake(async () => null); _removeFrameStub = stub(runner, "_removeFrame").callsFake(() => null); - for (const suite of runner._suites) - spy(suite, "prepare"); + for (const suite of runner._suites) spy(suite, "prepare"); expect(runner._suites).not.to.have.length(0); await runner.runAllSuites(); }); diff --git a/tests/run.mjs b/tests/run.mjs index b047015e0..9f01d8d40 100644 --- a/tests/run.mjs +++ b/tests/run.mjs @@ -35,12 +35,10 @@ function printHelp(message = "") { const options = commandLineArgs(optionDefinitions); -if ("help" in options) - printHelp(); +if ("help" in options) printHelp(); const BROWSER = options?.browser; -if (!BROWSER) - printHelp("No browser specified, use $BROWSER or --browser"); +if (!BROWSER) printHelp("No browser specified, use $BROWSER or --browser"); let capabilities; switch (BROWSER) { @@ -99,8 +97,7 @@ async function test() { await driver.get(`http://localhost:${PORT}/tests/index.html`); await driver.executeAsyncScript((callback) => { - if (window.benchmarkReady) - callback(); + if (window.benchmarkReady) callback(); window.addEventListener("benchmark-ready", () => callback(), { once: true }); }); diff --git a/tests/server.mjs b/tests/server.mjs index 0b209b897..0dea2e4ce 100644 --- a/tests/server.mjs +++ b/tests/server.mjs @@ -19,13 +19,11 @@ const STATIC_PATH = path.join(process.cwd(), "./"); const toBool = [() => true, () => false]; export default function serve(port) { - if (!port) - throw new Error("Port is required"); + if (!port) throw new Error("Port is required"); const prepareFile = async (url) => { const paths = [STATIC_PATH, url]; - if (url.endsWith("/")) - paths.push("index.html"); + if (url.endsWith("/")) paths.push("index.html"); const filePath = path.join(...paths); const pathTraversal = !filePath.startsWith(STATIC_PATH); const exists = await fs.promises.access(filePath).then(...toBool); From 2c2fd72c9802414e714b5c5b341d82dbf5b5b6cb Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Mon, 6 Jan 2025 15:35:21 +0100 Subject: [PATCH 03/11] fix --- about.html | 16 +- .../todomvc-localstorage/scripts/build.js | 6 +- .../todomvc-localstorage/src/controller.js | 12 +- .../todomvc-localstorage/src/helpers.js | 9 +- .../todomvc-localstorage/src/model.js | 6 +- .../todomvc-localstorage/src/store.js | 21 ++- .../todomvc-localstorage/src/template.js | 22 +-- experimental/todomvc-localstorage/src/view.js | 12 +- resources/benchmark-runner.mjs | 71 +++++--- resources/charts/chartjs.js | 9 +- resources/charts/observable-plot.js | 9 +- resources/developer-mode.mjs | 39 +++-- resources/editors/codemirror.js | 6 +- resources/editors/tiptap.js | 6 +- resources/main.mjs | 54 ++++-- resources/metric-ui.mjs | 34 ++-- resources/metric.mjs | 15 +- .../components/article/article-content.jsx | 47 +++--- .../src/components/article/article-header.jsx | 12 +- .../src/components/article/article-image.jsx | 3 +- .../src/components/article/article-tag.jsx | 3 +- .../src/components/article/article-text.jsx | 3 +- .../src/components/dialog/dialog.jsx | 6 +- .../src/components/message/message.jsx | 9 +- .../src/components/navlist/navlist.jsx | 20 ++- .../src/components/sitemap/sitemap.jsx | 8 +- .../news-next/src/components/toast/toast.jsx | 6 +- .../news-next/src/context/data-context.js | 3 +- .../newssite/news-next/src/pages/_app.js | 6 +- .../news-next/src/partials/page/page.jsx | 4 +- .../src/partials/section/section.jsx | 10 +- resources/scripts/sanitize-language/index.js | 3 +- resources/shared/benchmark.mjs | 9 +- resources/shared/params.mjs | 54 ++++-- resources/shared/test-invoker.mjs | 6 +- resources/shared/test-runner.mjs | 6 +- resources/statistics.mjs | 12 +- resources/suite-runner.mjs | 21 ++- resources/tests.mjs | 156 ++++++++++++------ .../app/todo-header/todo-header.component.ts | 3 +- .../src/app/todo-item/todo-item.component.ts | 9 +- .../angular/src/app/todos.service.ts | 3 +- .../backbone/scripts/build.js | 9 +- .../backbone/src/sync/backbone.sync.js | 21 ++- .../backbone/src/views/todo-view.js | 15 +- .../lit/src/lib/todo-app.ts | 4 +- .../lit/src/lib/todo-footer.ts | 5 +- .../lit/src/lib/todo-form.ts | 8 +- .../lit/src/lib/todo-item.ts | 11 +- .../lit/src/lib/todo-list.ts | 14 +- .../lit/src/lib/todos.ts | 9 +- .../lit/src/lib/utils.ts | 2 +- .../preact/src/app/app.js | 9 +- .../preact/src/app/footer.js | 6 +- .../preact/src/app/item.js | 12 +- .../preact/src/app/main.js | 4 +- .../preact/src/app/model.js | 4 +- .../react-redux/src/components/header.jsx | 3 +- .../react-redux/src/components/item.jsx | 6 +- .../react-redux/src/components/main.jsx | 3 +- .../react-redux/src/components/text-input.jsx | 6 +- .../react-redux/src/reducers/todos.js | 9 +- .../react/src/todo/components/input.jsx | 6 +- .../react/src/todo/components/item.jsx | 6 +- .../react/src/todo/components/main.jsx | 6 +- .../src/components/popovers/analytics.jsx | 3 +- .../src/components/popovers/date-picker.jsx | 4 +- .../src/components/popovers/filter.jsx | 4 +- .../src/components/popovers/notifications.jsx | 4 +- .../src/components/popovers/popover.jsx | 4 +- .../src/components/tree-area.jsx | 13 +- .../big-dom-generator/src/tree-generator.js | 9 +- .../plugins/constructable-css/index.js | 3 +- .../javascript-es5/scripts/build.js | 6 +- .../javascript-es5/src/controller.js | 12 +- .../javascript-es5/src/helpers.js | 9 +- .../javascript-es5/src/model.js | 6 +- .../javascript-es5/src/store.js | 9 +- .../javascript-es5/src/template.js | 22 +-- .../javascript-es5/src/view.js | 12 +- .../javascript-es6-webpack/src/app.js | 3 +- .../javascript-es6-webpack/src/controller.js | 18 +- .../javascript-es6-webpack/src/helpers.js | 12 +- .../javascript-es6-webpack/src/model.js | 9 +- .../javascript-es6-webpack/src/store.js | 27 ++- .../javascript-es6-webpack/src/template.js | 2 +- .../javascript-es6-webpack/src/view.js | 15 +- .../scripts/build.js | 12 +- .../components/todo-app/todo-app.component.js | 9 +- .../todo-bottombar.component.js | 18 +- .../todo-item/todo-item.component.js | 9 +- .../todo-list/todo-list.component.js | 24 ++- .../todo-topbar/todo-topbar.component.js | 9 +- .../src/hooks/useDoubleClick.js | 3 +- .../src/hooks/useKeyListener.js | 3 +- .../src/hooks/useRouter.js | 3 +- tests/benchmark-runner-tests.mjs | 3 +- tests/run.mjs | 6 +- tests/server.mjs | 6 +- 99 files changed, 794 insertions(+), 464 deletions(-) diff --git a/about.html b/about.html index 30e2f83df..cf68747e4 100644 --- a/about.html +++ b/about.html @@ -137,15 +137,13 @@

    About Speedometer 3

    -

    - Each step consists of the following phases: -

    -
    Sync:
    -
    Time spent in synchronous JS execution.
    -
    Async:
    -
    Time spent in asynchronous JS like Promise or setTimeout tasks scheduled by the sync-step.
    -
    -

    +

    Each step consists of the following phases:

    +
    +
    Sync:
    +
    Time spent in synchronous JS execution.
    +
    Async:
    +
    Time spent in asynchronous JS like Promise or setTimeout tasks scheduled by the sync-step.
    +

    The final benchmark score is calculated based of the inverse of geomean of all tests. We average the score over multiple iterations with the arithmetic mean. By using the geomean to combine the test durations we maintain the invariant that relative improvements are favoured equally amongst all tests, diff --git a/experimental/todomvc-localstorage/scripts/build.js b/experimental/todomvc-localstorage/scripts/build.js index 3e276b4e3..046de0e7e 100644 --- a/experimental/todomvc-localstorage/scripts/build.js +++ b/experimental/todomvc-localstorage/scripts/build.js @@ -22,14 +22,16 @@ const build = async () => { // copy src folder await fs.cp(sourceDirectory, targetDirectory, { recursive: true }, (err) => { - if (err) console.error(err); + if (err) + console.error(err); }); // copy html file await fs.copyFile(path.join(rootDirectory, htmlFile), path.join(targetDirectory, htmlFile)); // copy files to move - for (let i = 0; i < filesToMove.length; i++) await copy(filesToMove[i], path.join(targetDirectory, path.basename(filesToMove[i]))); + for (let i = 0; i < filesToMove.length; i++) + await copy(filesToMove[i], path.join(targetDirectory, path.basename(filesToMove[i]))); // read html file let html = await fs.readFile(path.join(targetDirectory, htmlFile), "utf8"); diff --git a/experimental/todomvc-localstorage/src/controller.js b/experimental/todomvc-localstorage/src/controller.js index 8886693f0..229b19dde 100644 --- a/experimental/todomvc-localstorage/src/controller.js +++ b/experimental/todomvc-localstorage/src/controller.js @@ -95,7 +95,8 @@ Controller.prototype.addItem = function (title) { var self = this; - if (title.trim() === "") return; + if (title.trim() === "") + return; self.model.create(title, function () { self.view.render("clearNewTodo"); @@ -187,7 +188,8 @@ }); }); - if (!silent) self._filter(); + if (!silent) + self._filter(); }; /** @@ -236,7 +238,8 @@ // If the last active route isn't "All", or we're switching routes, we // re-create the todo item elements, calling: // this.show[All|Active|Completed](); - if (force || this._lastActiveRoute !== "All" || this._lastActiveRoute !== activeRoute) this[`show${activeRoute}`](); + if (force || this._lastActiveRoute !== "All" || this._lastActiveRoute !== activeRoute) + this[`show${activeRoute}`](); this._lastActiveRoute = activeRoute; }; @@ -249,7 +252,8 @@ // items as they are marked complete or incomplete. this._activeRoute = currentPage; - if (currentPage === "") this._activeRoute = "All"; + if (currentPage === "") + this._activeRoute = "All"; this._filter(); diff --git a/experimental/todomvc-localstorage/src/helpers.js b/experimental/todomvc-localstorage/src/helpers.js index ae7862d4f..de93a88f2 100644 --- a/experimental/todomvc-localstorage/src/helpers.js +++ b/experimental/todomvc-localstorage/src/helpers.js @@ -23,7 +23,8 @@ var potentialElements = window.qsa(selector, target); var hasMatch = Array.prototype.indexOf.call(potentialElements, targetElement) >= 0; - if (hasMatch) handler.call(targetElement, event); + if (hasMatch) + handler.call(targetElement, event); } // https://developer.mozilla.org/en-US/docs/Web/Events/blur @@ -35,9 +36,11 @@ // Find the element's parent with the given tag name: // $parent(qs('a'), 'div'); window.$parent = function (element, tagName) { - if (!element.parentNode) return undefined; + if (!element.parentNode) + return undefined; - if (element.parentNode.tagName.toLowerCase() === tagName.toLowerCase()) return element.parentNode; + if (element.parentNode.tagName.toLowerCase() === tagName.toLowerCase()) + return element.parentNode; return window.$parent(element.parentNode, tagName); }; diff --git a/experimental/todomvc-localstorage/src/model.js b/experimental/todomvc-localstorage/src/model.js index 076a0ab37..2268fe853 100644 --- a/experimental/todomvc-localstorage/src/model.js +++ b/experimental/todomvc-localstorage/src/model.js @@ -102,8 +102,10 @@ this.storage.findAll(function (data) { data.forEach(function (todo) { - if (todo.completed) todos.completed++; - else todos.active++; + if (todo.completed) + todos.completed++; + else + todos.active++; todos.total++; }); diff --git a/experimental/todomvc-localstorage/src/store.js b/experimental/todomvc-localstorage/src/store.js index 3baf137d2..10fcdb222 100644 --- a/experimental/todomvc-localstorage/src/store.js +++ b/experimental/todomvc-localstorage/src/store.js @@ -7,11 +7,13 @@ _name: "", init: function (name, data = {}) { this._name = name; - if (!this.getData()) this.setData(data); + if (!this.getData()) + this.setData(data); }, getData: function () { const data = this._data[this._name]; - if (!data) return null; + if (!data) + return null; return JSON.parse(data); }, @@ -24,11 +26,13 @@ _name: "", init: function (name, data = {}) { this._name = name; - if (!this.getData()) this.setData(data); + if (!this.getData()) + this.setData(data); }, getData: function () { const data = window.localStorage.getItem(this._name); - if (!data) return null; + if (!data) + return null; return JSON.parse(data); }, @@ -72,7 +76,8 @@ * }); */ Store.prototype.find = function (query, callback) { - if (!callback) return; + if (!callback) + return; var todos = this.storage.getData(); @@ -80,7 +85,8 @@ this, todos.filter(function (todo) { for (var q in query) { - if (query[q] !== todo[q]) return false; + if (query[q] !== todo[q]) + return false; } return true; @@ -115,7 +121,8 @@ if (id) { for (var i = 0; i < todos.length; i++) { if (todos[i].id === id) { - for (var key in updateData) todos[i][key] = updateData[key]; + for (var key in updateData) + todos[i][key] = updateData[key]; break; } diff --git a/experimental/todomvc-localstorage/src/template.js b/experimental/todomvc-localstorage/src/template.js index bc119ee2a..fac7e2099 100644 --- a/experimental/todomvc-localstorage/src/template.js +++ b/experimental/todomvc-localstorage/src/template.js @@ -28,14 +28,14 @@ * @constructor */ function Template() { - this.defaultTemplate = - '

  • ' + - '
    ' + - '' + - "" + - '' + - "
    " + - "
  • "; + this.defaultTemplate + = '
  • ' + + '
    ' + + '' + + "" + + '' + + "
    " + + "
  • "; } /** @@ -100,8 +100,10 @@ * @returns {string} String containing the count */ Template.prototype.clearCompletedButton = function (completedTodos) { - if (completedTodos > 0) return "Clear completed"; - else return ""; + if (completedTodos > 0) + return "Clear completed"; + else + return ""; }; // Export to window diff --git a/experimental/todomvc-localstorage/src/view.js b/experimental/todomvc-localstorage/src/view.js index 3bb603729..b34323332 100644 --- a/experimental/todomvc-localstorage/src/view.js +++ b/experimental/todomvc-localstorage/src/view.js @@ -31,7 +31,8 @@ View.prototype._removeItem = function (id) { var elem = qs(`[data-id="${id}"]`); - if (elem) this.$todoList.removeChild(elem); + if (elem) + this.$todoList.removeChild(elem); }; View.prototype._clearCompletedButton = function (completedCount, visible) { @@ -47,7 +48,8 @@ View.prototype._elementComplete = function (id, completed) { var listItem = qs(`[data-id="${id}"]`); - if (!listItem) return; + if (!listItem) + return; listItem.className = completed ? "completed" : ""; @@ -58,7 +60,8 @@ View.prototype._editItem = function (id, title) { var listItem = qs(`[data-id="${id}"]`); - if (!listItem) return; + if (!listItem) + return; listItem.className = `${listItem.className} editing`; @@ -73,7 +76,8 @@ View.prototype._editItemDone = function (id, title) { var listItem = qs(`[data-id="${id}"]`); - if (!listItem) return; + if (!listItem) + return; var input = qs("input.edit", listItem); listItem.removeChild(input); diff --git a/resources/benchmark-runner.mjs b/resources/benchmark-runner.mjs index 94c8c80b2..fd86b0581 100644 --- a/resources/benchmark-runner.mjs +++ b/resources/benchmark-runner.mjs @@ -39,7 +39,8 @@ class Page { const resolveIfReady = () => { const element = this.querySelector(selector); let callback = resolveIfReady; - if (element) callback = () => resolve(element); + if (element) + callback = () => resolve(element); window.requestAnimationFrame(callback); }; resolveIfReady(); @@ -65,7 +66,8 @@ class Page { const lookupStartNode = this._frame.contentDocument; const element = getParent(lookupStartNode, path).querySelector(selector); - if (element === null) return null; + if (element === null) + return null; return this._wrapElement(element); } @@ -87,13 +89,15 @@ class Page { querySelectorAll(selector, path = []) { const lookupStartNode = this._frame.contentDocument; const elements = Array.from(getParent(lookupStartNode, path).querySelectorAll(selector)); - for (let i = 0; i < elements.length; i++) elements[i] = this._wrapElement(elements[i]); + for (let i = 0; i < elements.length; i++) + elements[i] = this._wrapElement(elements[i]); return elements; } getElementById(id) { const element = this._frame.contentDocument.getElementById(id); - if (element === null) return null; + if (element === null) + return null; return this._wrapElement(element); } @@ -149,7 +153,8 @@ class PageElement { if (eventName === "submit") // FIXME FireFox doesn't like `new Event('submit') this._dispatchSubmitEvent(); - else this.#node.dispatchEvent(new eventType(eventName, options)); + else + this.#node.dispatchEvent(new eventType(eventName, options)); } _dispatchSubmitEvent() { @@ -165,7 +170,8 @@ class PageElement { dispatchKeyEvent(type, keyCode, key, options) { let eventOptions = { bubbles: true, cancelable: true, keyCode, which: keyCode, key }; - if (options !== undefined) eventOptions = Object.assign(eventOptions, options); + if (options !== undefined) + eventOptions = Object.assign(eventOptions, options); const event = new KeyboardEvent(type, eventOptions); this.#node.dispatchEvent(event); } @@ -178,7 +184,8 @@ class PageElement { const screenX = clientX + contentWindow.screenX; const screenY = clientY + contentWindow.screenY; let eventOptions = { bubbles: true, cancelable: true, clientX, clientY, screenX, screenY }; - if (options !== undefined) eventOptions = Object.assign(eventOptions, options); + if (options !== undefined) + eventOptions = Object.assign(eventOptions, options); const event = new contentWindow.MouseEvent(type, eventOptions); this.#node.dispatchEvent(event); } @@ -195,14 +202,16 @@ class PageElement { const lookupStartNode = this.#node.shadowRoot ?? this.#node; const element = getParent(lookupStartNode, path).querySelector(selector); - if (element === null) return null; + if (element === null) + return null; return new PageElement(element); } querySelector(selector) { const element = this.#node.querySelector(selector); - if (element === null) return null; + if (element === null) + return null; return new PageElement(element); } } @@ -261,7 +270,7 @@ export const WarmupSuite = { // https://stackoverflow.com/a/47593316 function seededHashRandomNumberGenerator(a) { return function () { - var t = (a += 0x6d2b79f5); + var t = a += 0x6d2b79f5; t = Math.imul(t ^ (t >>> 15), t | 1); t ^= t + Math.imul(t ^ (t >>> 7), t | 61); return (t ^ (t >>> 14)) >>> 0; @@ -271,17 +280,20 @@ function seededHashRandomNumberGenerator(a) { export class BenchmarkRunner { constructor(suites, client) { this._suites = suites; - if (params.useWarmupSuite) this._suites = [WarmupSuite, ...suites]; + if (params.useWarmupSuite) + this._suites = [WarmupSuite, ...suites]; this._client = client; this._page = null; this._metrics = null; this._iterationCount = params.iterationCount; - if (params.shuffleSeed !== "off") this._suiteOrderRandomNumberGenerator = seededHashRandomNumberGenerator(params.shuffleSeed); + if (params.shuffleSeed !== "off") + this._suiteOrderRandomNumberGenerator = seededHashRandomNumberGenerator(params.shuffleSeed); } async runMultipleIterations(iterationCount) { this._iterationCount = iterationCount; - if (this._client?.willStartFirstIteration) await this._client.willStartFirstIteration(iterationCount); + if (this._client?.willStartFirstIteration) + await this._client.willStartFirstIteration(iterationCount); try { await this._runMultipleIterations(); @@ -293,7 +305,8 @@ export class BenchmarkRunner { } } - if (this._client?.didFinishLastIteration) await this._client.didFinishLastIteration(this._metrics); + if (this._client?.didFinishLastIteration) + await this._client.didFinishLastIteration(this._metrics); } async _runMultipleIterations() { @@ -327,7 +340,8 @@ export class BenchmarkRunner { style.top = "50%"; style.transform = "translate(-50%, -50%)"; - if (this._client?.willAddTestFrame) await this._client.willAddTestFrame(frame); + if (this._client?.willAddTestFrame) + await this._client.willAddTestFrame(frame); document.body.insertBefore(frame, document.body.firstChild); this._frame = frame; @@ -342,7 +356,8 @@ export class BenchmarkRunner { performance.mark(prepareStartLabel); let suites = [...this._suites]; - if (this._suiteOrderRandomNumberGenerator) this._shuffleSuites(suites); + if (this._suiteOrderRandomNumberGenerator) + this._shuffleSuites(suites); performance.mark(prepareEndLabel); performance.measure("runner-prepare", prepareStartLabel, prepareEndLabel); @@ -365,7 +380,8 @@ export class BenchmarkRunner { const suites = await this._prepareAllSuites(); try { for (const suite of suites) { - if (suite.disabled) continue; + if (suite.disabled) + continue; try { await this._appendFrame(); @@ -424,7 +440,8 @@ export class BenchmarkRunner { _appendIterationMetrics() { const getMetric = (name, unit = "ms") => this._metrics[name] || (this._metrics[name] = new Metric(name, unit)); const iterationTotalMetric = (i) => { - if (i >= params.iterationCount) throw new Error(`Requested iteration=${i} does not exist.`); + if (i >= params.iterationCount) + throw new Error(`Requested iteration=${i} does not exist.`); return getMetric(`Iteration-${i}-Total`); }; @@ -433,12 +450,15 @@ export class BenchmarkRunner { const results = items[name]; const metric = getMetric(prefix + name); metric.add(results.total ?? results); - if (metric.parent !== parent) parent.addChild(metric); - if (results.tests) collectSubMetrics(`${metric.name}${Metric.separator}`, results.tests, metric); + if (metric.parent !== parent) + parent.addChild(metric); + if (results.tests) + collectSubMetrics(`${metric.name}${Metric.separator}`, results.tests, metric); } }; const initializeMetrics = this._metrics === null; - if (initializeMetrics) this._metrics = { __proto__: null }; + if (initializeMetrics) + this._metrics = { __proto__: null }; const iterationResults = this._measuredValues.tests; collectSubMetrics("", iterationResults); @@ -446,18 +466,21 @@ export class BenchmarkRunner { if (initializeMetrics) { // Prepare all iteration metrics so they are listed at the end of // of the _metrics object, before "Total" and "Score". - for (let i = 0; i < this._iterationCount; i++) iterationTotalMetric(i).description = `Test totals for iteration ${i}`; + for (let i = 0; i < this._iterationCount; i++) + iterationTotalMetric(i).description = `Test totals for iteration ${i}`; getMetric("Geomean", "ms").description = "Geomean of test totals"; getMetric("Score", "score").description = "Scaled inverse of the Geomean"; } const geomean = getMetric("Geomean"); const iterationTotal = iterationTotalMetric(geomean.length); - for (const results of Object.values(iterationResults)) iterationTotal.add(results.total); + for (const results of Object.values(iterationResults)) + iterationTotal.add(results.total); iterationTotal.computeAggregatedMetrics(); geomean.add(iterationTotal.geomean); getMetric("Score").add(geomeanToScore(iterationTotal.geomean)); - for (const metric of Object.values(this._metrics)) metric.computeAggregatedMetrics(); + for (const metric of Object.values(this._metrics)) + metric.computeAggregatedMetrics(); } } diff --git a/resources/charts/chartjs.js b/resources/charts/chartjs.js index 59e8e2d89..76e81c6de 100644 --- a/resources/charts/chartjs.js +++ b/resources/charts/chartjs.js @@ -58,7 +58,8 @@ const opaqueCheckBox = document.getElementById("opaque-color"); let currentChart = null; function drawScattered(data) { - if (!preparedData) throw new Error("Please prepare the data first."); + if (!preparedData) + throw new Error("Please prepare the data first."); reset(); @@ -127,7 +128,8 @@ function drawScattered(data) { } function openTooltip() { - if (!currentChart) throw new Error("No chart is present, please draw a chart first"); + if (!currentChart) + throw new Error("No chart is present, please draw a chart first"); const renderedDataset = currentChart.getDatasetMeta(0); const node = currentChart.canvas; @@ -168,4 +170,5 @@ document.getElementById("open-tooltip").addEventListener("click", openTooltip); document.getElementById("reset").addEventListener("click", reset); document.getElementById("run-all").addEventListener("click", runAllTheThings); -if (import.meta.env.DEV) runAllTheThings(); +if (import.meta.env.DEV) + runAllTheThings(); diff --git a/resources/charts/observable-plot.js b/resources/charts/observable-plot.js index 046006cfb..f0ef7967f 100644 --- a/resources/charts/observable-plot.js +++ b/resources/charts/observable-plot.js @@ -124,7 +124,8 @@ function isReady() { } function addStackedBars() { - if (!isReady()) throw new Error("Please prepare the data first."); + if (!isReady()) + throw new Error("Please prepare the data first."); const options = { ...DEFAULT_OPTIONS, @@ -148,7 +149,8 @@ function addStackedBars() { } function addDottedBars() { - if (!isReady()) throw new Error("Please prepare the data first."); + if (!isReady()) + throw new Error("Please prepare the data first."); const data = [...preparedData.flightsByAirport] .flatMap(([iata, { origin, destination }]) => { @@ -227,4 +229,5 @@ document.getElementById("run-all").addEventListener("click", runAllTheThings); document.getElementById("airport-group-size-input").addEventListener("input", onGroupSizeInputChange); onGroupSizeInputChange(); -if (import.meta.env.DEV) runAllTheThings(); +if (import.meta.env.DEV) + runAllTheThings(); diff --git a/resources/developer-mode.mjs b/resources/developer-mode.mjs index 2dba744f2..2a79c79d7 100644 --- a/resources/developer-mode.mjs +++ b/resources/developer-mode.mjs @@ -130,8 +130,10 @@ function createUIForSuites() { label.onclick = (event) => { if (event?.ctrlKey || event?.metaKey) { for (let suiteIndex = 0; suiteIndex < Suites.length; suiteIndex++) { - if (Suites[suiteIndex] !== suite) setSuiteEnabled(suiteIndex, false); - else setSuiteEnabled(suiteIndex, true); + if (Suites[suiteIndex] !== suite) + setSuiteEnabled(suiteIndex, false); + else + setSuiteEnabled(suiteIndex, true); } } }; @@ -150,7 +152,8 @@ function createSuitesGlobalSelectButtons(setSuiteEnabled) { let button = document.createElement("button"); button.textContent = "Select all"; button.onclick = () => { - for (let suiteIndex = 0; suiteIndex < Suites.length; suiteIndex++) setSuiteEnabled(suiteIndex, true); + for (let suiteIndex = 0; suiteIndex < Suites.length; suiteIndex++) + setSuiteEnabled(suiteIndex, true); updateURL(); }; @@ -159,7 +162,8 @@ function createSuitesGlobalSelectButtons(setSuiteEnabled) { button = document.createElement("button"); button.textContent = "Unselect all"; button.onclick = () => { - for (let suiteIndex = 0; suiteIndex < Suites.length; suiteIndex++) setSuiteEnabled(suiteIndex, false); + for (let suiteIndex = 0; suiteIndex < Suites.length; suiteIndex++) + setSuiteEnabled(suiteIndex, false); updateURL(); }; @@ -174,7 +178,8 @@ function createSuitesTagsButton(setSuiteEnabled) { let i = 0; const kTagsPerLine = 3; for (const tag of Tags) { - if (tag === "all") continue; + if (tag === "all") + continue; if (!(i % kTagsPerLine)) { buttons = tags.appendChild(document.createElement("div")); buttons.className = "button-bar"; @@ -190,8 +195,10 @@ function createSuitesTagsButton(setSuiteEnabled) { const selectedTag = event.target.dataTag; for (let suiteIndex = 0; suiteIndex < Suites.length; suiteIndex++) { let enabled = Suites[suiteIndex].tags.includes(selectedTag); - if (invertSelection) enabled = !enabled; - if (extendSelection && !enabled) continue; + if (invertSelection) + enabled = !enabled; + if (extendSelection && !enabled) + continue; setSuiteEnabled(suiteIndex, enabled); } updateURL(); @@ -233,12 +240,15 @@ function updateURL() { // Try finding common tags that would result in the current suite selection. let commonTags = new Set(selectedSuites[0].tags); for (const suite of Suites) { - if (suite.disabled) suite.tags.forEach((tag) => commonTags.delete(tag)); - else commonTags = new Set(suite.tags.filter((tag) => commonTags.has(tag))); + if (suite.disabled) + suite.tags.forEach((tag) => commonTags.delete(tag)); + else + commonTags = new Set(suite.tags.filter((tag) => commonTags.has(tag))); } if (selectedSuites.length > 1 && commonTags.size) { const tags = [...commonTags][0]; - if (tags !== "default") url.searchParams.set("tags", tags); + if (tags !== "default") + url.searchParams.set("tags", tags); url.searchParams.delete("suites"); } else { url.searchParams.set("suites", selectedSuites.map((suite) => suite.name).join(",")); @@ -247,11 +257,14 @@ function updateURL() { const defaultParamKeys = ["iterationCount", "useWarmupSuite", "warmupBeforeSync", "waitBeforeSync"]; for (const paramKey of defaultParamKeys) { - if (params[paramKey] !== defaultParams[paramKey]) url.searchParams.set(paramKey, params[paramKey]); - else url.searchParams.delete(paramKey); + if (params[paramKey] !== defaultParams[paramKey]) + url.searchParams.set(paramKey, params[paramKey]); + else + url.searchParams.delete(paramKey); } // Only push state if changed url.search = decodeURIComponent(url.search); - if (url.href !== window.location.href) window.history.pushState({}, "", url); + if (url.href !== window.location.href) + window.history.pushState({}, "", url); } diff --git a/resources/editors/codemirror.js b/resources/editors/codemirror.js index ae66ae2dc..23cb57647 100644 --- a/resources/editors/codemirror.js +++ b/resources/editors/codemirror.js @@ -34,8 +34,10 @@ export default function (element, value) { format(on) { // https://codemirror.net/examples/config/ // https://discuss.codemirror.net/t/cm6-dynamically-switching-syntax-theme-w-reconfigure/2858/6 - if (on && extensions.length === 2) extensions.push(lang); - else if (!on && extensions.length === 3) extensions.pop(); + if (on && extensions.length === 2) + extensions.push(lang); + else if (!on && extensions.length === 3) + extensions.pop(); view.dispatch({ effects: StateEffect.reconfigure.of(extensions), diff --git a/resources/editors/tiptap.js b/resources/editors/tiptap.js index 8d49effe9..d8a0e6e57 100644 --- a/resources/editors/tiptap.js +++ b/resources/editors/tiptap.js @@ -33,8 +33,10 @@ export default function (element, value) { element.scrollTop = 0; }, format(on) { - if (on) editor.chain().focus().selectAll().setBold().setTextSelection(0).run(); - else editor.chain().focus().selectAll().unsetBold().setTextSelection(0).run(); + if (on) + editor.chain().focus().selectAll().setBold().setTextSelection(0).run(); + else + editor.chain().focus().selectAll().unsetBold().setTextSelection(0).run(); }, }; } diff --git a/resources/main.mjs b/resources/main.mjs index bbb7c8dfd..bbae96597 100644 --- a/resources/main.mjs +++ b/resources/main.mjs @@ -26,8 +26,10 @@ class MainBenchmarkClient { } start() { - if (this._isStepping()) this._clearStepping(); - else if (this._startBenchmark()) this._showSection("#running"); + if (this._isStepping()) + this._clearStepping(); + else if (this._startBenchmark()) + this._showSection("#running"); } step() { @@ -35,7 +37,8 @@ class MainBenchmarkClient { this._steppingPromise = new Promise((resolve) => { this._steppingResolver = resolve; }); - if (this._isStepping()) currentSteppingResolver(); + if (this._isStepping()) + currentSteppingResolver(); if (!this._isRunning) { this._startBenchmark(); this._showSection("#running"); @@ -59,7 +62,8 @@ class MainBenchmarkClient { } _startBenchmark() { - if (this._isRunning) return false; + if (this._isRunning) + return false; if (Suites.every((suite) => suite.disabled)) { const message = `No suites selected - "${params.suites}" does not exist.`; @@ -73,7 +77,8 @@ class MainBenchmarkClient { return false; } - if (!this._isStepping()) this._developerModeContainer?.remove(); + if (!this._isStepping()) + this._developerModeContainer?.remove(); this._progressCompleted = document.getElementById("progress-completed"); if (params.iterationCount < 50) { const progressNode = document.getElementById("progress"); @@ -110,7 +115,8 @@ class MainBenchmarkClient { async willRunTest(suite, test) { document.getElementById("info-label").textContent = suite.name; document.getElementById("info-progress").textContent = `${this._finishedTestCount} / ${this.stepCount}`; - if (this._steppingPromise) await this._awaitNextStep(suite, test); + if (this._steppingPromise) + await this._awaitNextStep(suite, test); } didFinishSuite() { @@ -134,12 +140,16 @@ class MainBenchmarkClient { this._metrics = metrics; const scoreResults = this._computeResults(this._measuredValuesList, "score"); - if (scoreResults.isValid) this._populateValidScore(scoreResults); - else this._populateInvalidScore(); + if (scoreResults.isValid) + this._populateValidScore(scoreResults); + else + this._populateInvalidScore(); this._populateDetailedResults(metrics); - if (params.developerMode) this.showResultsDetails(); - else this.showResultsSummary(); + if (params.developerMode) + this.showResultsDetails(); + else + this.showResultsSummary(); } handleError(error) { @@ -156,7 +166,8 @@ class MainBenchmarkClient { this._updateGaugeNeedle(scoreResults.mean); document.getElementById("result-number").textContent = scoreResults.formattedMean; - if (scoreResults.formattedDelta) document.getElementById("confidence-number").textContent = `\u00b1 ${scoreResults.formattedDelta}`; + if (scoreResults.formattedDelta) + document.getElementById("confidence-number").textContent = `\u00b1 ${scoreResults.formattedDelta}`; } _populateInvalidScore() { @@ -167,7 +178,8 @@ class MainBenchmarkClient { _computeResults(measuredValuesList, displayUnit) { function valueForUnit(measuredValues) { - if (displayUnit === "ms") return measuredValues.geomean; + if (displayUnit === "ms") + return measuredValues.geomean; return measuredValues.score; } @@ -292,14 +304,16 @@ class MainBenchmarkClient { button.onclick = this._startBenchmarkHandler.bind(this); }); - if (params.suites.length > 0 || params.tags.length > 0) Suites.enable(params.suites, params.tags); + if (params.suites.length > 0 || params.tags.length > 0) + Suites.enable(params.suites, params.tags); if (params.developerMode) { this._developerModeContainer = createDeveloperModeContainer(Suites); document.body.append(this._developerModeContainer); } - if (params.startAutomatically) this.start(); + if (params.startAutomatically) + this.start(); } _hashChangeHandler() { @@ -322,7 +336,8 @@ class MainBenchmarkClient { _logoClickHandler(event) { // Prevent any accidental UI changes during benchmark runs. - if (!this._isRunning) this._showSection("#home"); + if (!this._isRunning) + this._showSection("#home"); event.preventDefault(); return false; } @@ -337,7 +352,8 @@ class MainBenchmarkClient { _formattedJSONResult({ modern = false }) { const indent = " "; - if (modern) return JSON.stringify(this._metrics, undefined, indent); + if (modern) + return JSON.stringify(this._metrics, undefined, indent); return JSON.stringify(this._measuredValuesList, undefined, indent); } @@ -350,7 +366,8 @@ class MainBenchmarkClient { // TodoMVC-JavaScript-ES5/Adding100Items,num,...,num // ... const labels = ["Name"]; - for (let i = 0; i < params.iterationCount; i++) labels.push(`#${i + 1}`); + for (let i = 0; i < params.iterationCount; i++) + labels.push(`#${i + 1}`); labels.push("Mean"); const metrics = Array.from(Object.values(this._metrics)).filter((metric) => !metric.name.startsWith("Iteration-")); const metricsValues = metrics.map((metric) => [metric.name, ...metric.values, metric.mean].join(",")); @@ -386,7 +403,8 @@ class MainBenchmarkClient { _setLocationHash(hash) { if (hash === "#home" || hash === "") { - if (window.location.hash !== hash) window.location.hash = "#home"; + if (window.location.hash !== hash) + window.location.hash = "#home"; hash = "#home"; this._removeLocationHash(); } else { diff --git a/resources/metric-ui.mjs b/resources/metric-ui.mjs index ea48bbcb6..240863f19 100644 --- a/resources/metric-ui.mjs +++ b/resources/metric-ui.mjs @@ -68,7 +68,8 @@ function renderSubMetrics(viewParams) { ${renderMetricsTable(metrics)}
    `; const hasChildMetric = metrics.length > 0 && metrics[0].children.length > 0; - if (!hasChildMetric || !renderChildren) return valuesTable; + if (!hasChildMetric || !renderChildren) + return valuesTable; const subMetricWidth = width - subMetricMargin; const childColors = [...colors]; @@ -110,8 +111,10 @@ function renderMetricsTable(metrics, min, max) { for (const metric of metrics) { const prefixes = metric.name.split(Metric.separator); for (let i = commonPrefixes.length - 1; i >= 0; i--) { - if (commonPrefixes[i] !== prefixes[i]) commonPrefixes.pop(); + if (commonPrefixes[i] !== prefixes[i]) + commonPrefixes.pop(); } + } const commonPrefix = commonPrefixes.join(Metric.separator); let commonPrefixHeader = ""; @@ -133,7 +136,8 @@ function renderMetricsTable(metrics, min, max) { let columns = ""; for (const metric of metrics) { const value = metric.values[row]; - if (value === undefined) continue; + if (value === undefined) + continue; const delta = metric.max - metric.min; const percent = Math.max(Math.min((value - metric.min) / delta, 1), 0) * 100; const percentGradient = `background: linear-gradient(90deg, var(--foreground-alpha) ${percent}%, rgba(0,0,0,0) ${percent}%);`; @@ -176,8 +180,10 @@ function prepareScatterPlotValues(metrics, normalize = true) { const metric = metrics[metricIndex]; // If the mean is 0 we can't normalize values properly. const mean = metric.mean || 1; - if (!unit) unit = metric.unit; - else if (unit !== metric.unit) throw new Error("All metrics must have the same unit."); + if (!unit) + unit = metric.unit; + else if (unit !== metric.unit) + throw new Error("All metrics must have the same unit."); let width = metric.delta || 1; let center = mean; if (normalize) { @@ -196,7 +202,8 @@ function prepareScatterPlotValues(metrics, normalize = true) { const value = values[i]; let x = value; let normalized = (value / mean - 1) * toPercent; - if (normalize) x = normalized; + if (normalize) + x = normalized; const sign = normalized < 0 ? "-" : "+"; normalized = Math.abs(normalized); // Each value is mapped to a y-coordinate in the range of [metricIndex, metricIndex + 1] @@ -211,7 +218,8 @@ function prepareScatterPlotValues(metrics, normalize = true) { } function renderScatterPlot({ values, width = 500, height, trackHeight, xAxisPositiveOnly = false, xAxisShowZero = false, xAxisLabel, unit = "", colors = COLORS }) { - if (!height && !trackHeight) throw new Error("Either height or trackHeight must be specified"); + if (!height && !trackHeight) + throw new Error("Either height or trackHeight must be specified"); let xMin = Infinity; let xMax = 0; let yMin = Infinity; @@ -223,7 +231,8 @@ function renderScatterPlot({ values, width = 500, height, trackHeight, xAxisPosi yMin = Math.min(yMin, y); yMax = Math.max(yMax, y); } - if (xAxisPositiveOnly) xMin = Math.max(xMin, 0); + if (xAxisPositiveOnly) + xMin = Math.max(xMin, 0); // Max delta of values across each axis: const trackCount = Math.ceil(yMax - yMin) || 1; const spreadX = xMax - xMin; @@ -234,10 +243,13 @@ function renderScatterPlot({ values, width = 500, height, trackHeight, xAxisPosi let markerSize = 5; // Auto-adjust markers to [2px, 5px] for high iteration counts: const iterationsLimit = 20; - if (values.length > iterationsLimit) markerSize = 2 + (3 / values.length) * iterationsLimit; + if (values.length > iterationsLimit) + markerSize = 2 + (3 / values.length) * iterationsLimit; // Recalculate height: - if (height) trackHeight = (height - axisHeight - axisMarginY) / trackCount; - else height = trackCount * trackHeight + axisHeight + axisMarginY; + if (height) + trackHeight = (height - axisHeight - axisMarginY) / trackCount; + else + height = trackCount * trackHeight + axisHeight + axisMarginY; // Horizontal axis position: const axisY = height - axisHeight + axisMarginY; diff --git a/resources/metric.mjs b/resources/metric.mjs index 39acf5091..66830ee5c 100644 --- a/resources/metric.mjs +++ b/resources/metric.mjs @@ -6,7 +6,8 @@ export class Metric { static separator = "/"; constructor(name, unit = "ms") { - if (typeof name !== "string") throw new Error(`Invalid metric.name=${name}, expected string.`); + if (typeof name !== "string") + throw new Error(`Invalid metric.name=${name}, expected string.`); this.name = name; this.unit = unit; this.description = ""; @@ -48,12 +49,14 @@ export class Metric { get valueString() { const mean = this.mean.toFixed(2); - if (!this.percentDelta || !this.delta) return `${mean} ${this.unit}`; + if (!this.percentDelta || !this.delta) + return `${mean} ${this.unit}`; return `${mean} ± ${this.deltaString} ${this.unit}`; } get deltaString() { - if (!this.percentDelta || !this.delta) return ""; + if (!this.percentDelta || !this.delta) + return ""; return `${this.delta.toFixed(2)} (${this.percentDelta.toFixed(1)}%)`; } @@ -62,13 +65,15 @@ export class Metric { } addChild(metric) { - if (metric.parent) throw new Error("Cannot re-add sub metric"); + if (metric.parent) + throw new Error("Cannot re-add sub metric"); metric.parent = this; this.children.push(metric); } add(value) { - if (typeof value !== "number") throw new Error(`Adding invalid value=${value} to metric=${this.name}`); + if (typeof value !== "number") + throw new Error(`Adding invalid value=${value} to metric=${this.name}`); this.values.push(value); } diff --git a/resources/newssite/news-next/src/components/article/article-content.jsx b/resources/newssite/news-next/src/components/article/article-content.jsx index 76caef078..dd7840293 100644 --- a/resources/newssite/news-next/src/components/article/article-content.jsx +++ b/resources/newssite/news-next/src/components/article/article-content.jsx @@ -20,17 +20,16 @@ export default function ArticleContent({ type, content, display }) { return (
    ); @@ -40,18 +39,17 @@ export default function ArticleContent({ type, content, display }) { return (
    ); @@ -60,14 +58,14 @@ export default function ArticleContent({ type, content, display }) { if (type === "excerpt") { return (
      - {content.map((item) => ( + {content.map((item) =>
    • - ))} + )}
    ); } @@ -75,19 +73,18 @@ export default function ArticleContent({ type, content, display }) { if (type === "grid") { return (
    - {content.map((item) => ( + {content.map((item) =>
    - {item.url ? ( - + {item.url + ? - ) : ( - - )} + : + }
    - ))} + )}
    ); } @@ -95,12 +92,12 @@ export default function ArticleContent({ type, content, display }) { if (type === "preview") { return (
      - {content.map((item) => ( + {content.map((item) =>
    • - ))} + )}
    ); } diff --git a/resources/newssite/news-next/src/components/article/article-header.jsx b/resources/newssite/news-next/src/components/article/article-header.jsx index 1b0b3e737..8fe884fea 100644 --- a/resources/newssite/news-next/src/components/article/article-header.jsx +++ b/resources/newssite/news-next/src/components/article/article-header.jsx @@ -1,15 +1,15 @@ export default function ArticleHeader({ text, headerClass, link }) { - if (!text) return null; + if (!text) + return null; return (
    - {link ? ( - + {link + ?

    {text}

    - ) : ( -

    {text}

    - )} + :

    {text}

    + }
    ); } diff --git a/resources/newssite/news-next/src/components/article/article-image.jsx b/resources/newssite/news-next/src/components/article/article-image.jsx index 3e864c9d6..17fa92161 100644 --- a/resources/newssite/news-next/src/components/article/article-image.jsx +++ b/resources/newssite/news-next/src/components/article/article-image.jsx @@ -5,7 +5,8 @@ import ArticleTag from "./article-tag"; import styles from "news-site-css/dist/article.module.css"; export default function ArticleImage({ image, imageClass, meta }) { - if (!image) return null; + if (!image) + return null; return ( <> diff --git a/resources/newssite/news-next/src/components/article/article-tag.jsx b/resources/newssite/news-next/src/components/article/article-tag.jsx index 6e0966218..c8716671a 100644 --- a/resources/newssite/news-next/src/components/article/article-tag.jsx +++ b/resources/newssite/news-next/src/components/article/article-tag.jsx @@ -8,7 +8,8 @@ import FireIcon from "@/assets/fire-icon"; import styles from "news-site-css/dist/article.module.css"; export default function ArticleTag({ tag }) { - if (!tag) return null; + if (!tag) + return null; return (
    diff --git a/resources/newssite/news-next/src/components/article/article-text.jsx b/resources/newssite/news-next/src/components/article/article-text.jsx index 2ee9c6da0..3755f95e2 100644 --- a/resources/newssite/news-next/src/components/article/article-text.jsx +++ b/resources/newssite/news-next/src/components/article/article-text.jsx @@ -1,5 +1,6 @@ export default function ArticleText({ text, textClass, type = "p" }) { - if (!text) return null; + if (!text) + return null; const Tag = type; return {text}; diff --git a/resources/newssite/news-next/src/components/dialog/dialog.jsx b/resources/newssite/news-next/src/components/dialog/dialog.jsx index 37fcd31db..91b229a4f 100644 --- a/resources/newssite/news-next/src/components/dialog/dialog.jsx +++ b/resources/newssite/news-next/src/components/dialog/dialog.jsx @@ -17,8 +17,10 @@ export default function Dialog({ onClose }) { function toggleMotion(e) { setReduceMotion(e.target.checked); - if (e.target.checked) document.documentElement.classList.add("reduced-motion"); - else document.documentElement.classList.remove("reduced-motion"); + if (e.target.checked) + document.documentElement.classList.add("reduced-motion"); + else + document.documentElement.classList.remove("reduced-motion"); } return ( diff --git a/resources/newssite/news-next/src/components/message/message.jsx b/resources/newssite/news-next/src/components/message/message.jsx index 4c222bdc8..5894e2365 100644 --- a/resources/newssite/news-next/src/components/message/message.jsx +++ b/resources/newssite/news-next/src/components/message/message.jsx @@ -3,7 +3,8 @@ import classNames from "classnames"; import styles from "news-site-css/dist/message.module.css"; export function Message({ message, onClose }) { - if (!message) return null; + if (!message) + return null; const { title, description } = message; return ( @@ -16,11 +17,11 @@ export function Message({ message, onClose }) {
    - {title ? ( -
    + {title + ?

    {title}

    - ) : null} + : null}
    {description}
    diff --git a/resources/newssite/news-next/src/components/navlist/navlist.jsx b/resources/newssite/news-next/src/components/navlist/navlist.jsx index d82eacf63..352a10acd 100644 --- a/resources/newssite/news-next/src/components/navlist/navlist.jsx +++ b/resources/newssite/news-next/src/components/navlist/navlist.jsx @@ -11,24 +11,26 @@ export default function NavList({ callback, id }) { const dropdownItems = []; Object.keys(content).forEach((key) => { - if (content[key].priority === 1) navItems.push(key); - else if (content[key].priority === 2) dropdownItems.push(key); + if (content[key].priority === 1) + navItems.push(key); + else if (content[key].priority === 2) + dropdownItems.push(key); }); return (
      - {navItems.map((key) => ( + {navItems.map((key) => - ))} - {dropdownItems.length > 0 ? ( -
    • + )} + {dropdownItems.length > 0 + ?
    • - {dropdownItems.map((key) => ( + {dropdownItems.map((key) => - ))} + )}
    • - ) : null} + : null}
    ); } diff --git a/resources/newssite/news-next/src/components/sitemap/sitemap.jsx b/resources/newssite/news-next/src/components/sitemap/sitemap.jsx index bdc0c71d3..4747d38db 100644 --- a/resources/newssite/news-next/src/components/sitemap/sitemap.jsx +++ b/resources/newssite/news-next/src/components/sitemap/sitemap.jsx @@ -19,20 +19,20 @@ export default function Sitemap() { return (
      - {navItems.map((key) => ( + {navItems.map((key) =>
    • classNames({ [styles.active]: isActive })}>

      {content[key].name}

        - {content[key].sections.map((section) => ( + {content[key].sections.map((section) =>
      • {section.name}
      • - ))} + )}
    • - ))} + )}
    ); diff --git a/resources/newssite/news-next/src/components/toast/toast.jsx b/resources/newssite/news-next/src/components/toast/toast.jsx index e38f88143..d83fb879e 100644 --- a/resources/newssite/news-next/src/components/toast/toast.jsx +++ b/resources/newssite/news-next/src/components/toast/toast.jsx @@ -14,11 +14,11 @@ export default function Toast({ onClose, notification, onAccept, onReject }) { - {title ? ( -
    + {title + ?

    {title}

    - ) : null} + : null}
    {description}
    diff --git a/resources/newssite/news-next/src/context/data-context.js b/resources/newssite/news-next/src/context/data-context.js index c7250997a..61d24a8fe 100644 --- a/resources/newssite/news-next/src/context/data-context.js +++ b/resources/newssite/news-next/src/context/data-context.js @@ -28,7 +28,8 @@ export const DataContextProvider = ({ children }) => { export const useDataContext = () => { const dataContext = useContext(DataContext); - if (!dataContext) throw new Error("A DataProvider must be rendered before using useDataContext"); + if (!dataContext) + throw new Error("A DataProvider must be rendered before using useDataContext"); return dataContext; }; diff --git a/resources/newssite/news-next/src/pages/_app.js b/resources/newssite/news-next/src/pages/_app.js index ae379be1e..820529ccf 100644 --- a/resources/newssite/news-next/src/pages/_app.js +++ b/resources/newssite/news-next/src/pages/_app.js @@ -10,8 +10,8 @@ import Script from "next/script"; function App({ Component, pageProps }) { const [render, setRender] = useState(false); useEffect(() => setRender(true), []); - return render ? ( - <> + return render + ? <> - ) : null; + : null; } export default App; diff --git a/resources/newssite/news-next/src/partials/page/page.jsx b/resources/newssite/news-next/src/partials/page/page.jsx index 3a01351ee..c76a4fed2 100644 --- a/resources/newssite/news-next/src/partials/page/page.jsx +++ b/resources/newssite/news-next/src/partials/page/page.jsx @@ -30,9 +30,9 @@ export default function Page({ id }) { return ( <> - {content[id].sections.map((section) => ( + {content[id].sections.map((section) =>
    - ))} + )} {showPortal && content[id].notification ? createPortal(, document.getElementById("notifications-container")) : null} diff --git a/resources/newssite/news-next/src/partials/section/section.jsx b/resources/newssite/news-next/src/partials/section/section.jsx index 6b7c72609..df90ffe29 100644 --- a/resources/newssite/news-next/src/partials/section/section.jsx +++ b/resources/newssite/news-next/src/partials/section/section.jsx @@ -5,15 +5,15 @@ import styles from "news-site-css/dist/layout.module.css"; export default function Section({ section }) { return ( <> - {section.name ? ( -
    + {section.name + ?

    {section.name}

    - ) : null} + : null}
    - {section.articles.map((article, index) => ( + {section.articles.map((article, index) =>
    - ))} + )}
    ); diff --git a/resources/scripts/sanitize-language/index.js b/resources/scripts/sanitize-language/index.js index e4f62b624..b0d4c5ab9 100644 --- a/resources/scripts/sanitize-language/index.js +++ b/resources/scripts/sanitize-language/index.js @@ -31,7 +31,8 @@ async function readAndReplace(fileName) { return replacements.get(matched); }); - if (contents !== sanitized) await fs.writeFile(fileName, sanitized); + if (contents !== sanitized) + await fs.writeFile(fileName, sanitized); } async function sanitize() { diff --git a/resources/shared/benchmark.mjs b/resources/shared/benchmark.mjs index e9939fdcb..b691e86ac 100644 --- a/resources/shared/benchmark.mjs +++ b/resources/shared/benchmark.mjs @@ -86,20 +86,23 @@ export class BenchmarkConnector { this.name = name; this.version = version; - if (!name || !version) console.warn("No name or version supplied, to create a unique appId"); + if (!name || !version) + console.warn("No name or version supplied, to create a unique appId"); this.appId = name && version ? `${name}-${version}` : -1; this.onMessage = this.onMessage.bind(this); } async onMessage(event) { - if (event.data.id !== this.appId || event.data.key !== "benchmark-connector") return; + if (event.data.id !== this.appId || event.data.key !== "benchmark-connector") + return; switch (event.data.type) { case "benchmark-suite": const params = new Params(new URLSearchParams(window.location.search)); const suite = this.suites[event.data.name]; - if (!suite) console.error(`Suite with the name of "${event.data.name}" not found!`); + if (!suite) + console.error(`Suite with the name of "${event.data.name}" not found!`); const { result } = await suite.runAndRecord(params, (test) => this.sendMessage({ type: "step-complete", status: "success", appId: this.appId, name: this.name, test })); this.sendMessage({ type: "suite-complete", status: "success", appId: this.appId, result }); this.disconnect(); diff --git a/resources/shared/params.mjs b/resources/shared/params.mjs index 325e49f41..57b3adc52 100644 --- a/resources/shared/params.mjs +++ b/resources/shared/params.mjs @@ -27,7 +27,8 @@ export class Params { shuffleSeed = "off"; constructor(searchParams = undefined) { - if (searchParams) this._copyFromSearchParams(searchParams); + if (searchParams) + this._copyFromSearchParams(searchParams); if (!this.developerMode) { Object.freeze(this.viewport); Object.freeze(this); @@ -36,7 +37,8 @@ export class Params { _parseInt(value, errorMessage) { const number = Number(value); - if (!Number.isInteger(number) && errorMessage) throw new Error(`Invalid ${errorMessage} param: '${value}', expected int.`); + if (!Number.isInteger(number) && errorMessage) + throw new Error(`Invalid ${errorMessage} param: '${value}', expected int.`); return parseInt(number); } @@ -54,43 +56,51 @@ export class Params { this.shuffleSeed = this._parseShuffleSeed(searchParams); const unused = Array.from(searchParams.keys()); - if (unused.length > 0) console.error("Got unused search params", unused); + if (unused.length > 0) + console.error("Got unused search params", unused); } _parseBooleanParam(searchParams, paramKey) { - if (!searchParams.has(paramKey)) return false; + if (!searchParams.has(paramKey)) + return false; searchParams.delete(paramKey); return true; } _parseIntParam(searchParams, paramKey, minValue) { - if (!searchParams.has(paramKey)) return defaultParams[paramKey]; + if (!searchParams.has(paramKey)) + return defaultParams[paramKey]; const parsedValue = this._parseInt(searchParams.get(paramKey), "waitBeforeSync"); - if (parsedValue < minValue) throw new Error(`Invalid ${paramKey} param: '${parsedValue}', value must be >= ${minValue}.`); + if (parsedValue < minValue) + throw new Error(`Invalid ${paramKey} param: '${parsedValue}', value must be >= ${minValue}.`); searchParams.delete(paramKey); return parsedValue; } _parseViewport(searchParams) { - if (!searchParams.has("viewport")) return defaultParams.viewport; + if (!searchParams.has("viewport")) + return defaultParams.viewport; const viewportParam = searchParams.get("viewport"); const [width, height] = viewportParam.split("x"); const viewport = { width: this._parseInt(width, "viewport.width"), height: this._parseInt(height, "viewport.height"), }; - if (this.viewport.width < 800 || this.viewport.height < 600) throw new Error(`Invalid viewport param: ${viewportParam}`); + if (this.viewport.width < 800 || this.viewport.height < 600) + throw new Error(`Invalid viewport param: ${viewportParam}`); searchParams.delete("viewport"); return viewport; } _parseSuites(searchParams) { if (searchParams.has("suite") || searchParams.has("suites")) { - if (searchParams.has("suite") && searchParams.has("suites")) throw new Error("Params 'suite' and 'suites' can not be used together."); + if (searchParams.has("suite") && searchParams.has("suites")) + throw new Error("Params 'suite' and 'suites' can not be used together."); const value = searchParams.get("suite") || searchParams.get("suites"); const suites = value.split(","); - if (suites.length === 0) throw new Error("No suites selected"); + if (suites.length === 0) + throw new Error("No suites selected"); searchParams.delete("suite"); searchParams.delete("suites"); return suites; @@ -99,23 +109,28 @@ export class Params { } _parseTags(searchParams) { - if (!searchParams.has("tags")) return defaultParams.tags; - if (this.suites.length) throw new Error("'suites' and 'tags' cannot be used together."); + if (!searchParams.has("tags")) + return defaultParams.tags; + if (this.suites.length) + throw new Error("'suites' and 'tags' cannot be used together."); const tags = searchParams.get("tags").split(","); searchParams.delete("tags"); return tags; } _parseMeasurementMethod(searchParams) { - if (!searchParams.has("measurementMethod")) return defaultParams.measurementMethod; + if (!searchParams.has("measurementMethod")) + return defaultParams.measurementMethod; const measurementMethod = searchParams.get("measurementMethod"); - if (measurementMethod !== "raf") throw new Error(`Invalid measurement method: '${measurementMethod}', must be 'raf'.`); + if (measurementMethod !== "raf") + throw new Error(`Invalid measurement method: '${measurementMethod}', must be 'raf'.`); searchParams.delete("measurementMethod"); return measurementMethod; } _parseShuffleSeed(searchParams) { - if (!searchParams.has("shuffleSeed")) return defaultParams.shuffleSeed; + if (!searchParams.has("shuffleSeed")) + return defaultParams.shuffleSeed; let shuffleSeed = searchParams.get("shuffleSeed"); if (shuffleSeed !== "off") { if (shuffleSeed === "generate") { @@ -124,7 +139,8 @@ export class Params { } else { shuffleSeed = parseInt(shuffleSeed); } - if (!Number.isInteger(shuffleSeed)) throw new Error(`Invalid shuffle seed: '${shuffleSeed}', must be either 'off', 'generate' or an integer.`); + if (!Number.isInteger(shuffleSeed)) + throw new Error(`Invalid shuffle seed: '${shuffleSeed}', must be either 'off', 'generate' or an integer.`); } searchParams.delete("shuffleSeed"); return shuffleSeed; @@ -133,12 +149,14 @@ export class Params { toSearchParamsObject() { const rawParams = { __proto__: null }; for (const [key, value] of Object.entries(this)) { - if (value === defaultParams[key]) continue; + if (value === defaultParams[key]) + continue; rawParams[key] = value; } // Either suites or params can be used at the same time. - if (rawParams.suites?.length && rawParams.tags?.length) delete rawParams.suites; + if (rawParams.suites?.length && rawParams.tags?.length) + delete rawParams.suites; rawParams.viewport = `${this.viewport.width}x${this.viewport.height}`; return new URLSearchParams(rawParams); diff --git a/resources/shared/test-invoker.mjs b/resources/shared/test-invoker.mjs index 413b00fd4..c20c40b8f 100644 --- a/resources/shared/test-invoker.mjs +++ b/resources/shared/test-invoker.mjs @@ -10,8 +10,10 @@ class TestInvoker { export class RAFTestInvoker extends TestInvoker { start() { return new Promise((resolve) => { - if (this._params.waitBeforeSync) setTimeout(() => this._scheduleCallbacks(resolve), this._params.waitBeforeSync); - else this._scheduleCallbacks(resolve); + if (this._params.waitBeforeSync) + setTimeout(() => this._scheduleCallbacks(resolve), this._params.waitBeforeSync); + else + this._scheduleCallbacks(resolve); }); } diff --git a/resources/shared/test-runner.mjs b/resources/shared/test-runner.mjs index c5cd0894e..1b5c2598e 100644 --- a/resources/shared/test-runner.mjs +++ b/resources/shared/test-runner.mjs @@ -36,7 +36,8 @@ export class TestRunner { performance.mark("warmup-start"); const startTime = performance.now(); // Infinite loop for the specified ms. - while (performance.now() - startTime < this.#params.warmupBeforeSync) continue; + while (performance.now() - startTime < this.#params.warmupBeforeSync) + continue; performance.mark("warmup-end"); } performance.mark(syncStartLabel); @@ -63,7 +64,8 @@ export class TestRunner { asyncTime = asyncEndTime - asyncStartTime; - if (this.#params.warmupBeforeSync) performance.measure("warmup", "warmup-start", "warmup-end"); + if (this.#params.warmupBeforeSync) + performance.measure("warmup", "warmup-start", "warmup-end"); performance.measure(`${suiteName}.${testName}-sync`, syncStartLabel, syncEndLabel); performance.measure(`${suiteName}.${testName}-async`, asyncStartLabel, asyncEndLabel); }; diff --git a/resources/statistics.mjs b/resources/statistics.mjs index 35350e2c8..ba3018a12 100644 --- a/resources/statistics.mjs +++ b/resources/statistics.mjs @@ -46,13 +46,15 @@ export function squareSum(values) { // With sum and sum of squares, we can compute the sample standard deviation in O(1). // See https://rniwa.com/2012-11-10/sample-standard-deviation-in-terms-of-sum-and-square-sum-of-samples/ export function sampleStandardDeviation(numberOfSamples, sum, squareSum) { - if (numberOfSamples < 2) return 0; + if (numberOfSamples < 2) + return 0; return Math.sqrt(squareSum / (numberOfSamples - 1) - (sum * sum) / (numberOfSamples - 1) / numberOfSamples); } export function supportedConfidenceLevels() { const supportedLevels = []; - for (let quantile in tDistributionInverseCDF) supportedLevels.push((1 - (1 - quantile) * 2).toFixed(2)); + for (let quantile in tDistributionInverseCDF) + supportedLevels.push((1 - (1 - quantile) * 2).toFixed(2)); return supportedLevels; } @@ -63,11 +65,13 @@ export function confidenceIntervalDelta(confidenceLevel, numberOfSamples, sum, s const supportedIntervals = supportedConfidenceLevels().map((level) => `${level * 100}%`); throw `We only support ${supportedIntervals.join(", ")} confidence intervals.`; } - if (numberOfSamples - 2 < 0) return NaN; + if (numberOfSamples - 2 < 0) + return NaN; const cdfForProbability = tDistributionInverseCDF[probability]; let degreesOfFreedom = numberOfSamples - 1; - if (degreesOfFreedom > cdfForProbability.length) degreesOfFreedom = cdfForProbability.length - 1; + if (degreesOfFreedom > cdfForProbability.length) + degreesOfFreedom = cdfForProbability.length - 1; // tDistributionQuantile(degreesOfFreedom, confidenceLevel) * sampleStandardDeviation / sqrt(numberOfSamples) * S/sqrt(numberOfSamples) const quantile = cdfForProbability[degreesOfFreedom - 1]; // The first entry is for the one degree of freedom. diff --git a/resources/suite-runner.mjs b/resources/suite-runner.mjs index e366f51f5..0daf616ec 100644 --- a/resources/suite-runner.mjs +++ b/resources/suite-runner.mjs @@ -72,7 +72,8 @@ export class SuiteRunner { performance.mark(suiteStartLabel); for (const test of this.#suite.tests) { - if (this.#client?.willRunTest) await this.#client.willRunTest(this.#suite, test); + if (this.#client?.willRunTest) + await this.#client.willRunTest(this.#suite, test); const testRunner = new TestRunner(this.#frame, this.#page, this.#params, this.#suite, test, this._recordTestResults); await testRunner.runTest(); @@ -89,7 +90,8 @@ export class SuiteRunner { // privacy.resistFingerprinting preference), it's possible that the measured // total duration for an entire is 0. const suiteTotal = this.#suiteResults.total; - if (suiteTotal === 0) throw new Error(`Got invalid 0-time total for suite ${this.#suite.name}: ${suiteTotal}`); + if (suiteTotal === 0) + throw new Error(`Got invalid 0-time total for suite ${this.#suite.name}: ${suiteTotal}`); } async _loadFrame() { @@ -103,7 +105,8 @@ export class SuiteRunner { _recordTestResults = async (test, syncTime, asyncTime) => { // Skip reporting updates for the warmup suite. - if (this.#suite === WarmupSuite) return; + if (this.#suite === WarmupSuite) + return; const total = syncTime + asyncTime; this.#suiteResults.tests[test.name] = { tests: { Sync: syncTime, Async: asyncTime }, total: total }; @@ -111,7 +114,8 @@ export class SuiteRunner { }; async _updateClient(suite = this.#suite) { - if (this.#client?.didFinishSuite) await this.#client.didFinishSuite(suite); + if (this.#client?.didFinishSuite) + await this.#client.didFinishSuite(suite); } } @@ -179,17 +183,20 @@ export class RemoteSuiteRunner extends SuiteRunner { _handlePostMessage(event) { const callback = this.postMessageCallbacks.get(event.data.type); - if (callback) callback(event); + if (callback) + callback(event); } _startSubscription(type, callback) { - if (this.postMessageCallbacks.has(type)) throw new Error("Callback exists already"); + if (this.postMessageCallbacks.has(type)) + throw new Error("Callback exists already"); this.postMessageCallbacks.set(type, callback); } _stopSubscription(type) { - if (!this.postMessageCallbacks.has(type)) throw new Error("Callback does not exist"); + if (!this.postMessageCallbacks.has(type)) + throw new Error("Callback does not exist"); this.postMessageCallbacks.delete(type); } diff --git a/resources/tests.mjs b/resources/tests.mjs index 158e2b6a8..d7cf6794a 100644 --- a/resources/tests.mjs +++ b/resources/tests.mjs @@ -16,12 +16,15 @@ Suites.enable = function (names, tags) { if (names?.length) { const lowerCaseNames = names.map((each) => each.toLowerCase()); this.forEach((suite) => { - if (lowerCaseNames.includes(suite.name.toLowerCase())) suite.disabled = false; - else suite.disabled = true; + if (lowerCaseNames.includes(suite.name.toLowerCase())) + suite.disabled = false; + else + suite.disabled = true; }); } else if (tags?.length) { tags.forEach((tag) => { - if (!Tags.has(tag)) console.error(`Unknown Suites tag: "${tag}"`); + if (!Tags.has(tag)) + console.error(`Unknown Suites tag: "${tag}"`); }); const tagsSet = new Set(tags); this.forEach((suite) => { @@ -33,7 +36,8 @@ Suites.enable = function (names, tags) { suite.disabled = !("default" in suite.tags); }); } - if (this.some((suite) => !suite.disabled)) return; + if (this.some((suite) => !suite.disabled)) + return; let message, debugInfo; if (names?.length) { message = `Suites "${names}" does not match any Suite. No tests to run.`; @@ -72,11 +76,13 @@ Suites.push({ }), new BenchmarkTestStep("CompletingAllItems", (page) => { const checkboxes = page.querySelectorAll(".toggle"); - for (let i = 0; i < numberOfItemsToAdd; i++) checkboxes[i].click(); + for (let i = 0; i < numberOfItemsToAdd; i++) + checkboxes[i].click(); }), new BenchmarkTestStep("DeletingAllItems", (page) => { const deleteButtons = page.querySelectorAll(".destroy"); - for (let i = numberOfItemsToAdd - 1; i >= 0; i--) deleteButtons[i].click(); + for (let i = numberOfItemsToAdd - 1; i >= 0; i--) + deleteButtons[i].click(); }), ], }); @@ -133,11 +139,13 @@ Suites.push({ }), new BenchmarkTestStep("CompletingAllItems", (page) => { const checkboxes = page.querySelectorAll(".toggle"); - for (let i = 0; i < numberOfItemsToAdd; i++) checkboxes[i].click(); + for (let i = 0; i < numberOfItemsToAdd; i++) + checkboxes[i].click(); }), new BenchmarkTestStep("DeletingAllItems", (page) => { const deleteButtons = page.querySelectorAll(".destroy"); - for (let i = numberOfItemsToAdd - 1; i >= 0; i--) deleteButtons[i].click(); + for (let i = numberOfItemsToAdd - 1; i >= 0; i--) + deleteButtons[i].click(); }), ], }); @@ -161,11 +169,13 @@ Suites.push({ }), new BenchmarkTestStep("CompletingAllItems", (page) => { const checkboxes = page.querySelectorAll(".toggle"); - for (let i = 0; i < numberOfItemsToAdd; i++) checkboxes[i].click(); + for (let i = 0; i < numberOfItemsToAdd; i++) + checkboxes[i].click(); }), new BenchmarkTestStep("DeletingAllItems", (page) => { const deleteButtons = page.querySelectorAll(".destroy"); - for (let i = numberOfItemsToAdd - 1; i >= 0; i--) deleteButtons[i].click(); + for (let i = numberOfItemsToAdd - 1; i >= 0; i--) + deleteButtons[i].click(); }), ], }); @@ -190,11 +200,13 @@ Suites.push({ }), new BenchmarkTestStep("CompletingAllItems", (page) => { const checkboxes = page.querySelectorAll(".toggle"); - for (let i = 0; i < numberOfItemsToAdd; i++) checkboxes[i].click(); + for (let i = 0; i < numberOfItemsToAdd; i++) + checkboxes[i].click(); }), new BenchmarkTestStep("DeletingAllItems", (page) => { const deleteButtons = page.querySelectorAll(".destroy"); - for (let i = numberOfItemsToAdd - 1; i >= 0; i--) deleteButtons[i].click(); + for (let i = numberOfItemsToAdd - 1; i >= 0; i--) + deleteButtons[i].click(); }), ], }); @@ -218,11 +230,13 @@ Suites.push({ }), new BenchmarkTestStep("CompletingAllItems", (page) => { const checkboxes = page.querySelectorAll(".toggle"); - for (let i = 0; i < numberOfItemsToAdd; i++) checkboxes[i].click(); + for (let i = 0; i < numberOfItemsToAdd; i++) + checkboxes[i].click(); }), new BenchmarkTestStep("DeletingAllItems", (page) => { const deleteButtons = page.querySelectorAll(".destroy"); - for (let i = numberOfItemsToAdd - 1; i >= 0; i--) deleteButtons[i].click(); + for (let i = numberOfItemsToAdd - 1; i >= 0; i--) + deleteButtons[i].click(); }), ], }); @@ -314,11 +328,13 @@ Suites.push({ }), new BenchmarkTestStep("CompletingAllItems", (page) => { const checkboxes = page.querySelectorAll(".toggle"); - for (let i = 0; i < numberOfItemsToAdd; i++) checkboxes[i].click(); + for (let i = 0; i < numberOfItemsToAdd; i++) + checkboxes[i].click(); }), new BenchmarkTestStep("DeletingAllItems", (page) => { const deleteButtons = page.querySelectorAll(".destroy"); - for (let i = numberOfItemsToAdd - 1; i >= 0; i--) deleteButtons[i].click(); + for (let i = numberOfItemsToAdd - 1; i >= 0; i--) + deleteButtons[i].click(); }), ], }); @@ -342,11 +358,13 @@ Suites.push({ }), new BenchmarkTestStep("CompletingAllItems", (page) => { const checkboxes = page.querySelectorAll(".toggle"); - for (let i = 0; i < numberOfItemsToAdd; i++) checkboxes[i].click(); + for (let i = 0; i < numberOfItemsToAdd; i++) + checkboxes[i].click(); }), new BenchmarkTestStep("DeletingAllItems", (page) => { const deleteButtons = page.querySelectorAll(".destroy"); - for (let i = numberOfItemsToAdd - 1; i >= 0; i--) deleteButtons[i].click(); + for (let i = numberOfItemsToAdd - 1; i >= 0; i--) + deleteButtons[i].click(); }), ], }); @@ -369,11 +387,13 @@ Suites.push({ }), new BenchmarkTestStep("CompletingAllItems", (page) => { const checkboxes = page.querySelectorAll(".toggle"); - for (let i = 0; i < numberOfItemsToAdd; i++) checkboxes[i].click(); + for (let i = 0; i < numberOfItemsToAdd; i++) + checkboxes[i].click(); }), new BenchmarkTestStep("DeletingAllItems", (page) => { const deleteButtons = page.querySelectorAll(".destroy"); - for (let i = numberOfItemsToAdd - 1; i >= 0; i--) deleteButtons[i].click(); + for (let i = numberOfItemsToAdd - 1; i >= 0; i--) + deleteButtons[i].click(); }), ], }); @@ -397,11 +417,13 @@ Suites.push({ }), new BenchmarkTestStep("CompletingAllItems", (page) => { const checkboxes = page.querySelectorAll(".toggle"); - for (let i = 0; i < numberOfItemsToAdd; i++) checkboxes[i].click(); + for (let i = 0; i < numberOfItemsToAdd; i++) + checkboxes[i].click(); }), new BenchmarkTestStep("DeletingAllItems", (page) => { const deleteButtons = page.querySelectorAll(".destroy"); - for (let i = numberOfItemsToAdd - 1; i >= 0; i--) deleteButtons[i].click(); + for (let i = numberOfItemsToAdd - 1; i >= 0; i--) + deleteButtons[i].click(); }), ], }); @@ -426,11 +448,13 @@ Suites.push({ }), new BenchmarkTestStep("CompletingAllItems", (page) => { const checkboxes = page.querySelectorAll(".toggle"); - for (let i = 0; i < numberOfItemsToAdd; i++) checkboxes[i].click(); + for (let i = 0; i < numberOfItemsToAdd; i++) + checkboxes[i].click(); }), new BenchmarkTestStep("DeletingAllItems", (page) => { const deleteButtons = page.querySelectorAll(".destroy"); - for (let i = numberOfItemsToAdd - 1; i >= 0; i--) deleteButtons[i].click(); + for (let i = numberOfItemsToAdd - 1; i >= 0; i--) + deleteButtons[i].click(); }), ], }); @@ -456,11 +480,13 @@ Suites.push({ }), new BenchmarkTestStep("CompletingAllItems", (page) => { const checkboxes = page.querySelectorAll(".toggle"); - for (let i = 0; i < numberOfItemsToAdd; i++) checkboxes[i].click(); + for (let i = 0; i < numberOfItemsToAdd; i++) + checkboxes[i].click(); }), new BenchmarkTestStep("DeletingAllItems", (page) => { const deleteButtons = page.querySelectorAll(".destroy"); - for (let i = numberOfItemsToAdd - 1; i >= 0; i--) deleteButtons[i].click(); + for (let i = numberOfItemsToAdd - 1; i >= 0; i--) + deleteButtons[i].click(); }), ], }); @@ -485,11 +511,13 @@ Suites.push({ }), new BenchmarkTestStep("CompletingAllItems", (page) => { const checkboxes = page.querySelectorAll(".toggle"); - for (let i = 0; i < numberOfItemsToAdd; i++) checkboxes[i].click(); + for (let i = 0; i < numberOfItemsToAdd; i++) + checkboxes[i].click(); }), new BenchmarkTestStep("DeletingAllItems", (page) => { const deleteButtons = page.querySelectorAll(".destroy"); - for (let i = numberOfItemsToAdd - 1; i >= 0; i--) deleteButtons[i].click(); + for (let i = numberOfItemsToAdd - 1; i >= 0; i--) + deleteButtons[i].click(); }), ], }); @@ -513,11 +541,13 @@ Suites.push({ }), new BenchmarkTestStep("CompletingAllItems", (page) => { const checkboxes = page.querySelectorAll(".toggle"); - for (let i = 0; i < numberOfItemsToAdd; i++) checkboxes[i].click(); + for (let i = 0; i < numberOfItemsToAdd; i++) + checkboxes[i].click(); }), new BenchmarkTestStep("DeletingAllItems", (page) => { const deleteButtons = page.querySelectorAll(".destroy"); - for (let i = numberOfItemsToAdd - 1; i >= 0; i--) deleteButtons[i].click(); + for (let i = numberOfItemsToAdd - 1; i >= 0; i--) + deleteButtons[i].click(); }), ], }); @@ -541,11 +571,13 @@ Suites.push({ }), new BenchmarkTestStep("CompletingAllItems", (page) => { const checkboxes = page.querySelectorAll(".toggle"); - for (let i = 0; i < numberOfItemsToAdd; i++) checkboxes[i].click(); + for (let i = 0; i < numberOfItemsToAdd; i++) + checkboxes[i].click(); }), new BenchmarkTestStep("DeletingAllItems", (page) => { const deleteButtons = page.querySelectorAll(".destroy"); - for (let i = numberOfItemsToAdd - 1; i >= 0; i--) deleteButtons[i].click(); + for (let i = numberOfItemsToAdd - 1; i >= 0; i--) + deleteButtons[i].click(); }), ], }); @@ -570,11 +602,13 @@ Suites.push({ }), new BenchmarkTestStep("CompletingAllItems", (page) => { const checkboxes = page.querySelectorAll(".toggle"); - for (let i = 0; i < numberOfItemsToAdd; i++) checkboxes[i].click(); + for (let i = 0; i < numberOfItemsToAdd; i++) + checkboxes[i].click(); }), new BenchmarkTestStep("DeletingAllItems", (page) => { const deleteButtons = page.querySelectorAll(".destroy"); - for (let i = numberOfItemsToAdd - 1; i >= 0; i--) deleteButtons[i].click(); + for (let i = numberOfItemsToAdd - 1; i >= 0; i--) + deleteButtons[i].click(); }), ], }); @@ -597,10 +631,12 @@ Suites.push({ } }), new BenchmarkTestStep("CompletingAllItems", (page) => { - for (let i = 1; i <= numberOfItemsToAdd; i++) page.querySelector(`li:nth-child(${i}) .toggle`).click(); + for (let i = 1; i <= numberOfItemsToAdd; i++) + page.querySelector(`li:nth-child(${i}) .toggle`).click(); }), new BenchmarkTestStep("DeletingAllItems", (page) => { - for (let i = numberOfItemsToAdd - 1; i >= 0; i--) page.querySelector(".destroy").click(); + for (let i = numberOfItemsToAdd - 1; i >= 0; i--) + page.querySelector(".destroy").click(); }), ], }); @@ -624,10 +660,12 @@ Suites.push({ } }), new BenchmarkTestStep("CompletingAllItems", (page) => { - for (let i = 1; i <= numberOfItemsToAdd; i++) page.querySelector(`li:nth-child(${i}) .toggle`).click(); + for (let i = 1; i <= numberOfItemsToAdd; i++) + page.querySelector(`li:nth-child(${i}) .toggle`).click(); }), new BenchmarkTestStep("DeletingAllItems", (page) => { - for (let i = numberOfItemsToAdd - 1; i >= 0; i--) page.querySelector(".destroy").click(); + for (let i = numberOfItemsToAdd - 1; i >= 0; i--) + page.querySelector(".destroy").click(); }), ], }); @@ -651,11 +689,13 @@ Suites.push({ }), new BenchmarkTestStep("CompletingAllItems", (page) => { const checkboxes = page.querySelectorAll(".toggle"); - for (let i = 0; i < numberOfItemsToAdd; i++) checkboxes[i].click(); + for (let i = 0; i < numberOfItemsToAdd; i++) + checkboxes[i].click(); }), new BenchmarkTestStep("DeletingAllItems", (page) => { const deleteButtons = page.querySelectorAll(".destroy"); - for (let i = numberOfItemsToAdd - 1; i >= 0; i--) deleteButtons[i].click(); + for (let i = numberOfItemsToAdd - 1; i >= 0; i--) + deleteButtons[i].click(); }), ], }); @@ -678,11 +718,13 @@ Suites.push({ }), new BenchmarkTestStep("CompletingAllItems", (page) => { const checkboxes = page.querySelectorAll(".toggle"); - for (let i = 0; i < numberOfItemsToAdd; i++) checkboxes[i].click(); + for (let i = 0; i < numberOfItemsToAdd; i++) + checkboxes[i].click(); }), new BenchmarkTestStep("DeletingAllItems", (page) => { const deleteButtons = page.querySelectorAll(".destroy"); - for (let i = numberOfItemsToAdd - 1; i >= 0; i--) deleteButtons[i].click(); + for (let i = numberOfItemsToAdd - 1; i >= 0; i--) + deleteButtons[i].click(); }), ], }); @@ -706,11 +748,13 @@ Suites.push({ }), new BenchmarkTestStep("CompletingAllItems", (page) => { const checkboxes = page.querySelectorAll(".toggle"); - for (let i = 0; i < numberOfItemsToAdd; i++) checkboxes[i].click(); + for (let i = 0; i < numberOfItemsToAdd; i++) + checkboxes[i].click(); }), new BenchmarkTestStep("DeletingAllItems", (page) => { const deleteButtons = page.querySelectorAll(".destroy"); - for (let i = numberOfItemsToAdd - 1; i >= 0; i--) deleteButtons[i].click(); + for (let i = numberOfItemsToAdd - 1; i >= 0; i--) + deleteButtons[i].click(); }), ], }); @@ -733,11 +777,13 @@ Suites.push({ }), new BenchmarkTestStep("CompletingAllItems", (page) => { const checkboxes = page.querySelectorAll(".toggle"); - for (let i = 0; i < numberOfItemsToAdd; i++) checkboxes[i].click(); + for (let i = 0; i < numberOfItemsToAdd; i++) + checkboxes[i].click(); }), new BenchmarkTestStep("DeletingAllItems", (page) => { const deleteButtons = page.querySelectorAll(".destroy"); - for (let i = numberOfItemsToAdd - 1; i >= 0; i--) deleteButtons[i].click(); + for (let i = numberOfItemsToAdd - 1; i >= 0; i--) + deleteButtons[i].click(); }), ], }); @@ -1004,7 +1050,8 @@ Suites.push({ const coords = (i) => ({ clientX: x + i * 10, clientY: y + i * 2, bubbles: true, cancelable: true }); for (let i = 0; i < 5; i++) { cursor.dispatchEvent("mousedown", coords(0), MouseEvent); - for (let j = 0; j < 10; j++) cursor.dispatchEvent("mousemove", coords(j), MouseEvent); + for (let j = 0; j < 10; j++) + cursor.dispatchEvent("mousemove", coords(j), MouseEvent); cursor.dispatchEvent("mouseup", coords(10), MouseEvent); } }), @@ -1019,7 +1066,8 @@ Suites.push({ bubbles: true, cancelable: true, }; - for (let i = 0; i < 15; i++) cursor.dispatchEvent("wheel", event, WheelEvent); + for (let i = 0; i < 15; i++) + cursor.dispatchEvent("wheel", event, WheelEvent); }), ], }); @@ -1067,10 +1115,14 @@ Suites.push({ Object.freeze(Suites); Suites.forEach((suite) => { - if (!suite.tags) suite.tags = []; - if (suite.url.startsWith("experimental/")) suite.tags.unshift("all", "experimental"); - else if (suite.disabled) suite.tags.unshift("all"); - else suite.tags.unshift("all", "default"); + if (!suite.tags) + suite.tags = []; + if (suite.url.startsWith("experimental/")) + suite.tags.unshift("all", "experimental"); + else if (suite.disabled) + suite.tags.unshift("all"); + else + suite.tags.unshift("all", "default"); Object.freeze(suite.tags); Object.freeze(suite.steps); }); diff --git a/resources/todomvc/architecture-examples/angular/src/app/todo-header/todo-header.component.ts b/resources/todomvc/architecture-examples/angular/src/app/todo-header/todo-header.component.ts index 49a53f781..8d2dbc69e 100644 --- a/resources/todomvc/architecture-examples/angular/src/app/todo-header/todo-header.component.ts +++ b/resources/todomvc/architecture-examples/angular/src/app/todo-header/todo-header.component.ts @@ -14,7 +14,8 @@ export class TodoHeaderComponent { addTodo() { const title = this.titleFormControl.getRawValue()?.trim(); - if (!title) return; + if (!title) + return; this.todosService.addItem(title); this.titleFormControl.setValue(""); diff --git a/resources/todomvc/architecture-examples/angular/src/app/todo-item/todo-item.component.ts b/resources/todomvc/architecture-examples/angular/src/app/todo-item/todo-item.component.ts index e17e3fa75..b483438f5 100644 --- a/resources/todomvc/architecture-examples/angular/src/app/todo-item/todo-item.component.ts +++ b/resources/todomvc/architecture-examples/angular/src/app/todo-item/todo-item.component.ts @@ -47,13 +47,16 @@ export class TodoItemComponent implements AfterViewChecked { updateTodo() { const title = this.titleFormControl.getRawValue()?.trimEnd(); - if (!title) this.deleteEvent.emit(this.todo); - else this.todo.title = title; + if (!title) + this.deleteEvent.emit(this.todo); + else + this.todo.title = title; this.isEditing = false; } ngAfterViewChecked(): void { - if (this.isEditing) this.inputRef?.nativeElement.focus(); + if (this.isEditing) + this.inputRef?.nativeElement.focus(); } } diff --git a/resources/todomvc/architecture-examples/angular/src/app/todos.service.ts b/resources/todomvc/architecture-examples/angular/src/app/todos.service.ts index 7d663de75..02cad243b 100644 --- a/resources/todomvc/architecture-examples/angular/src/app/todos.service.ts +++ b/resources/todomvc/architecture-examples/angular/src/app/todos.service.ts @@ -5,7 +5,8 @@ function uuid() { let uuid = ""; for (let i = 0; i < 32; i++) { const random = (Math.random() * 16) | 0; - if (i === 8 || i === 12 || i === 16 || i === 20) uuid += "-"; + if (i === 8 || i === 12 || i === 16 || i === 20) + uuid += "-"; uuid += (i === 12 ? 4 : i === 16 ? (random & 3) | 8 : random).toString(16); } diff --git a/resources/todomvc/architecture-examples/backbone/scripts/build.js b/resources/todomvc/architecture-examples/backbone/scripts/build.js index 7a0ce32f1..ff06b6773 100644 --- a/resources/todomvc/architecture-examples/backbone/scripts/build.js +++ b/resources/todomvc/architecture-examples/backbone/scripts/build.js @@ -29,20 +29,23 @@ const build = async () => { // copy src folder await fs.cp(sourceDirectory, targetDirectory, { recursive: true }, (err) => { - if (err) console.error(err); + if (err) + console.error(err); }); // copy html file await fs.copyFile(path.join(rootDirectory, htmlFile), path.join(targetDirectory, htmlFile)); // copy files to move - for (let i = 0; i < filesToMove.length; i++) await copy(filesToMove[i], path.join(targetDirectory, path.basename(filesToMove[i]))); + for (let i = 0; i < filesToMove.length; i++) + await copy(filesToMove[i], path.join(targetDirectory, path.basename(filesToMove[i]))); // read html file let html = await fs.readFile(path.join(targetDirectory, htmlFile), "utf8"); // remove base paths from files to move - for (let i = 0; i < filesToMove.length; i++) html = html.replace(filesToMove[i], path.basename(filesToMove[i])); + for (let i = 0; i < filesToMove.length; i++) + html = html.replace(filesToMove[i], path.basename(filesToMove[i])); // remove basePath from source directory const basePath = `${path.basename(sourceDirectory)}/`; diff --git a/resources/todomvc/architecture-examples/backbone/src/sync/backbone.sync.js b/resources/todomvc/architecture-examples/backbone/src/sync/backbone.sync.js index 715c46f20..0eaa3ed89 100644 --- a/resources/todomvc/architecture-examples/backbone/src/sync/backbone.sync.js +++ b/resources/todomvc/architecture-examples/backbone/src/sync/backbone.sync.js @@ -31,7 +31,8 @@ Backbone.sync = (function (method, model, options) { size += 1; // if a success callback was provided, execute it. - if (options.success) options.success(model, model.toJSON(), options); + if (options.success) + options.success(model, model.toJSON(), options); // resolve the deferred. deferred.resolve(model); @@ -44,13 +45,15 @@ Backbone.sync = (function (method, model, options) { cache[model.id] = model; // if a success callback was provided, execute it. - if (options.success) options.success(model, model.toJSON(), options); + if (options.success) + options.success(model, model.toJSON(), options); deferred.resolve(model); // if this model doesn't exist yet, we can't update it } else { - if (options.error) options.error(model, "Model not found"); + if (options.error) + options.error(model, "Model not found"); deferred.reject(model); } @@ -59,12 +62,14 @@ Backbone.sync = (function (method, model, options) { // as long as it exists if (cache[model.id]) { // if a success callback was provided, execute it. - if (options.success) options.success(model, cache[model.id].toJSON(), options); + if (options.success) + options.success(model, cache[model.id].toJSON(), options); // resolve deferred.resolve(model); } else { - if (options.error) options.error(model, "Model not found"); + if (options.error) + options.error(model, "Model not found"); deferred.reject(model); } @@ -78,14 +83,16 @@ Backbone.sync = (function (method, model, options) { // and trigger the success callback. Note we're passing an // empty object as the second argument, because a deletion // would result in an empty return from the server. - if (options.success) options.success(model, {}, options); + if (options.success) + options.success(model, {}, options); // resolve the deferred deferred.resolve(model); // otherwise, error that the model doesn't exist. } else { - if (options.error) options.error(model, "Model not found"); + if (options.error) + options.error(model, "Model not found"); deferred.reject(model); } } diff --git a/resources/todomvc/architecture-examples/backbone/src/views/todo-view.js b/resources/todomvc/architecture-examples/backbone/src/views/todo-view.js index c37f60f9d..801060075 100644 --- a/resources/todomvc/architecture-examples/backbone/src/views/todo-view.js +++ b/resources/todomvc/architecture-examples/backbone/src/views/todo-view.js @@ -45,7 +45,8 @@ var app = app || {}; // `id` change. It's known Backbone LocalStorage bug, therefore // we've to create a workaround. // https://github.com/tastejs/todomvc/issues/469 - if (this.model.changed.id !== undefined) return null; + if (this.model.changed.id !== undefined) + return null; this.$el.html(this.template(this.model.toJSON())); this.$el.toggleClass("completed", this.model.get("completed")); @@ -84,17 +85,21 @@ var app = app || {}; // longer being edited. Relying on the CSS class here has the // benefit of us not having to maintain state in the DOM and the // JavaScript logic. - if (!this.$el.hasClass("editing")) return; + if (!this.$el.hasClass("editing")) + return; - if (trimmedValue) this.model.save({ title: trimmedValue }); - else this.clear(); + if (trimmedValue) + this.model.save({ title: trimmedValue }); + else + this.clear(); this.$el.removeClass("editing"); }, // If you hit `enter`, we're through editing the item. updateOnEnter: function (e) { - if (e.which === ENTER_KEY) this.close(); + if (e.which === ENTER_KEY) + this.close(); }, // If you're pressing `escape` we revert your change by simply leaving diff --git a/resources/todomvc/architecture-examples/lit/src/lib/todo-app.ts b/resources/todomvc/architecture-examples/lit/src/lib/todo-app.ts index bc066b285..36a50f75f 100644 --- a/resources/todomvc/architecture-examples/lit/src/lib/todo-app.ts +++ b/resources/todomvc/architecture-examples/lit/src/lib/todo-app.ts @@ -86,8 +86,8 @@ export class TodoApp extends LitElement {
    `; diff --git a/resources/todomvc/architecture-examples/lit/src/lib/todo-footer.ts b/resources/todomvc/architecture-examples/lit/src/lib/todo-footer.ts index 7245673cf..db8c243a7 100644 --- a/resources/todomvc/architecture-examples/lit/src/lib/todo-footer.ts +++ b/resources/todomvc/architecture-examples/lit/src/lib/todo-footer.ts @@ -85,10 +85,11 @@ export class TodoFooter extends LitElement { @updateOnEvent("change") @property({ attribute: false }) - todoList?: Todos; + todoList?: Todos; override render() { - if (this.todoList === undefined || this.todoList.all.length === 0) return nothing; + if (this.todoList === undefined || this.todoList.all.length === 0) + return nothing; const allFilter = filterLink({ text: "All", diff --git a/resources/todomvc/architecture-examples/lit/src/lib/todo-form.ts b/resources/todomvc/architecture-examples/lit/src/lib/todo-form.ts index eeef32359..cd661fda9 100644 --- a/resources/todomvc/architecture-examples/lit/src/lib/todo-form.ts +++ b/resources/todomvc/architecture-examples/lit/src/lib/todo-form.ts @@ -36,7 +36,7 @@ export class TodoForm extends LitElement { @updateOnEvent("change") @property({ attribute: false }) - todoList?: Todos; + todoList?: Todos; override render() { return html``; @@ -46,13 +46,15 @@ export class TodoForm extends LitElement { #onChange() { const { value } = this.newTodoInput; - if (value.length > 0) this.dispatchEvent(new AddTodoEvent(value)); + if (value.length > 0) + this.dispatchEvent(new AddTodoEvent(value)); this.newTodoInput.value = ""; } #onKeydown(e: KeyboardEvent) { - if (e.key === "Enter") this.#onChange(); + if (e.key === "Enter") + this.#onChange(); } } diff --git a/resources/todomvc/architecture-examples/lit/src/lib/todo-item.ts b/resources/todomvc/architecture-examples/lit/src/lib/todo-item.ts index 2081de86a..ee3a0395a 100644 --- a/resources/todomvc/architecture-examples/lit/src/lib/todo-item.ts +++ b/resources/todomvc/architecture-examples/lit/src/lib/todo-item.ts @@ -139,16 +139,16 @@ export class TodoItem extends LitElement { ]; @property() - todoId = ""; + todoId = ""; @property() - text = ""; + text = ""; @property({ type: Boolean }) - completed = false; + completed = false; @state() - isEditing: boolean = false; + isEditing: boolean = false; override render() { const itemClassList = { @@ -189,7 +189,8 @@ export class TodoItem extends LitElement { } #captureEscape(e: KeyboardEvent) { - if (e.key === "escape") this.#abortEdit(e); + if (e.key === "escape") + this.#abortEdit(e); } #abortEdit(e: Event) { diff --git a/resources/todomvc/architecture-examples/lit/src/lib/todo-list.ts b/resources/todomvc/architecture-examples/lit/src/lib/todo-list.ts index 78921821a..3be86c024 100644 --- a/resources/todomvc/architecture-examples/lit/src/lib/todo-list.ts +++ b/resources/todomvc/architecture-examples/lit/src/lib/todo-list.ts @@ -88,22 +88,22 @@ export class TodoList extends LitElement { @updateOnEvent("change") @property({ attribute: false }) - todoList?: Todos; + todoList?: Todos; override render() { return html` ${(this.todoList?.all.length ?? 0) > 0 - ? html` + ? html` ` - : nothing} + : nothing} `; } diff --git a/resources/todomvc/architecture-examples/lit/src/lib/todos.ts b/resources/todomvc/architecture-examples/lit/src/lib/todos.ts index 20a8f1efe..f2d02ca96 100644 --- a/resources/todomvc/architecture-examples/lit/src/lib/todos.ts +++ b/resources/todomvc/architecture-examples/lit/src/lib/todos.ts @@ -122,7 +122,8 @@ export class Todos extends EventTarget { update(edit: TodoEdit) { const todo = this.#todos.find((todo) => todo.id === edit.id); - if (todo === undefined) return; + if (todo === undefined) + return; Object.assign(todo, edit); this.#notifyChange(); @@ -130,7 +131,8 @@ export class Todos extends EventTarget { toggle(id: string) { const todo = this.#todos.find((todo) => todo.id === id); - if (todo === undefined) return; + if (todo === undefined) + return; todo.completed = !todo.completed; this.#notifyChange(); @@ -169,7 +171,8 @@ export class Todos extends EventTarget { #filterFromUrl() { let filter = /#\/(.*)/.exec(window.location.hash)?.[1]; - if (isTodoFilter(filter)) return filter; + if (isTodoFilter(filter)) + return filter; return "all"; } diff --git a/resources/todomvc/architecture-examples/lit/src/lib/utils.ts b/resources/todomvc/architecture-examples/lit/src/lib/utils.ts index 5775f8494..16a753cbf 100644 --- a/resources/todomvc/architecture-examples/lit/src/lib/utils.ts +++ b/resources/todomvc/architecture-examples/lit/src/lib/utils.ts @@ -18,7 +18,7 @@ export const updateOnEvent = (eventName: string) => (target: ListenerCarryingEle const newDescriptor = { ...descriptor, set(this: ListenerCarryingElement, v: EventTarget) { - const listener = (this.__updateOnEventListener ??= () => this.requestUpdate()); + const listener = this.__updateOnEventListener ??= () => this.requestUpdate(); const oldValue = get!.call(this); oldValue?.removeEventListener?.(eventName, listener); v?.addEventListener?.(eventName, listener); diff --git a/resources/todomvc/architecture-examples/preact/src/app/app.js b/resources/todomvc/architecture-examples/preact/src/app/app.js index 7c353bcf4..a46a642f4 100644 --- a/resources/todomvc/architecture-examples/preact/src/app/app.js +++ b/resources/todomvc/architecture-examples/preact/src/app/app.js @@ -12,7 +12,8 @@ const getRoute = () => { .split("/") .pop(); - if (!FILTERS[route]) route = "all"; + if (!FILTERS[route]) + route = "all"; return route; }; @@ -63,12 +64,12 @@ export default function App() { return ( <> - {model.getTodos().length > 0 ? ( - <> + {model.getTodos().length > 0 + ? <> - ) : null} + : null} ); } diff --git a/resources/todomvc/architecture-examples/preact/src/app/footer.js b/resources/todomvc/architecture-examples/preact/src/app/footer.js index 90eb10caa..14fdd96bd 100644 --- a/resources/todomvc/architecture-examples/preact/src/app/footer.js +++ b/resources/todomvc/architecture-examples/preact/src/app/footer.js @@ -25,11 +25,11 @@ export default function TodoFooter({ todos, route, onClearCompleted }) { - {completedTodoCount > 0 && ( - - )} + } ); } diff --git a/resources/todomvc/architecture-examples/preact/src/app/item.js b/resources/todomvc/architecture-examples/preact/src/app/item.js index c8c2ffa1f..26fe09acb 100644 --- a/resources/todomvc/architecture-examples/preact/src/app/item.js +++ b/resources/todomvc/architecture-examples/preact/src/app/item.js @@ -27,8 +27,10 @@ export default function TodoItem({ onSave, onRemove, onToggle, todo, index }) { } function handleKeyDown(e) { - if (e.key === "Escape") setEditing(false); - else if (e.key === "Enter") handleSubmit(e); + if (e.key === "Escape") + setEditing(false); + else if (e.key === "Enter") + handleSubmit(e); } function handleDoubleClick() { @@ -51,14 +53,14 @@ export default function TodoItem({ onSave, onRemove, onToggle, todo, index }) { ' + - "" + - ""; + this.defaultTemplate + = '
  • ' + + '
    ' + + '' + + "" + + '' + + "
    " + + "
  • "; } /** @@ -100,8 +100,10 @@ * @returns {string} String containing the count */ Template.prototype.clearCompletedButton = function (completedTodos) { - if (completedTodos > 0) return "Clear completed"; - else return ""; + if (completedTodos > 0) + return "Clear completed"; + else + return ""; }; // Export to window diff --git a/resources/todomvc/vanilla-examples/javascript-es5/src/view.js b/resources/todomvc/vanilla-examples/javascript-es5/src/view.js index 3bb603729..b34323332 100644 --- a/resources/todomvc/vanilla-examples/javascript-es5/src/view.js +++ b/resources/todomvc/vanilla-examples/javascript-es5/src/view.js @@ -31,7 +31,8 @@ View.prototype._removeItem = function (id) { var elem = qs(`[data-id="${id}"]`); - if (elem) this.$todoList.removeChild(elem); + if (elem) + this.$todoList.removeChild(elem); }; View.prototype._clearCompletedButton = function (completedCount, visible) { @@ -47,7 +48,8 @@ View.prototype._elementComplete = function (id, completed) { var listItem = qs(`[data-id="${id}"]`); - if (!listItem) return; + if (!listItem) + return; listItem.className = completed ? "completed" : ""; @@ -58,7 +60,8 @@ View.prototype._editItem = function (id, title) { var listItem = qs(`[data-id="${id}"]`); - if (!listItem) return; + if (!listItem) + return; listItem.className = `${listItem.className} editing`; @@ -73,7 +76,8 @@ View.prototype._editItemDone = function (id, title) { var listItem = qs(`[data-id="${id}"]`); - if (!listItem) return; + if (!listItem) + return; var input = qs("input.edit", listItem); listItem.removeChild(input); diff --git a/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/app.js b/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/app.js index 7f5dc761e..866753165 100644 --- a/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/app.js +++ b/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/app.js @@ -28,7 +28,8 @@ function Todo(name) { /* HOT MODULE SPECIFIC */ if (module.hot) { module.hot.accept(function (err) {}); - if (document.readyState === "complete") onLoad(); + if (document.readyState === "complete") + onLoad(); } window.addEventListener("load", onLoad); diff --git a/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/controller.js b/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/controller.js index e0f6127a8..76a2db5b6 100644 --- a/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/controller.js +++ b/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/controller.js @@ -54,7 +54,8 @@ class Controller { * object and it'll handle the DOM insertion and saving of the new item. */ addItem(title) { - if (title.trim() === "") return; + if (title.trim() === "") + return; this.model.create(title, () => { this.view.render("clearNewTodo"); @@ -111,7 +112,8 @@ class Controller { */ removeCompletedItems() { this.model.read({ completed: true }, (data) => { - for (let item of data) this.removeItem(item.id); + for (let item of data) + this.removeItem(item.id); }); this._filter(); @@ -131,7 +133,8 @@ class Controller { this.view.render("elementComplete", { id, completed }); }); - if (!silent) this._filter(); + if (!silent) + this._filter(); } /** @@ -140,7 +143,8 @@ class Controller { */ toggleAll(completed) { this.model.read({ completed: !completed }, (data) => { - for (let item of data) this.toggleComplete(item.id, completed, true); + for (let item of data) + this.toggleComplete(item.id, completed, true); }); this._filter(); @@ -177,7 +181,8 @@ class Controller { // If the last active route isn't "All", or we're switching routes, we // re-create the todo item elements, calling: // this.show[All|Active|Completed]() - if (force || this._lastActiveRoute !== "All" || this._lastActiveRoute !== activeRoute) this[`show${activeRoute}`](); + if (force || this._lastActiveRoute !== "All" || this._lastActiveRoute !== activeRoute) + this[`show${activeRoute}`](); this._lastActiveRoute = activeRoute; } @@ -190,7 +195,8 @@ class Controller { // items as they are marked complete or incomplete. this._activeRoute = currentPage; - if (currentPage === "") this._activeRoute = "All"; + if (currentPage === "") + this._activeRoute = "All"; this._filter(); diff --git a/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/helpers.js b/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/helpers.js index 6a0e5b515..c0cb47a64 100644 --- a/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/helpers.js +++ b/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/helpers.js @@ -26,16 +26,19 @@ const $delegate = (target, selector, type, handler) => { const potentialElements = qsa(selector, target); const hasMatch = Array.prototype.indexOf.call(potentialElements, targetElement) >= 0; - if (hasMatch) handler.call(targetElement, event); + if (hasMatch) + handler.call(targetElement, event); } }; // Find the element's parent with the given tag name: // $parent(qs('a'), 'div'); const $parent = (element, tagName) => { - if (!element.parentNode) return undefined; + if (!element.parentNode) + return undefined; - if (element.parentNode.tagName.toLowerCase() === tagName.toLowerCase()) return element.parentNode; + if (element.parentNode.tagName.toLowerCase() === tagName.toLowerCase()) + return element.parentNode; return $parent(element.parentNode, tagName); }; @@ -46,7 +49,8 @@ const $parent = (element, tagName) => { // x ~== [1,3] const remove = (array, thing) => { const index = array.indexOf(thing); - if (index === -1) return array; + if (index === -1) + return array; return array.splice(index, 1); }; diff --git a/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/model.js b/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/model.js index c081c4cff..b37df66af 100644 --- a/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/model.js +++ b/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/model.js @@ -89,7 +89,8 @@ class Model { * Returns a count of all todos */ getCount(callback) { - if (!callback) return; + if (!callback) + return; const stats = { active: 0, @@ -99,8 +100,10 @@ class Model { this.storage.findAll((data) => { for (let todo of data) { - if (todo.completed) stats.completed++; - else stats.active++; + if (todo.completed) + stats.completed++; + else + stats.active++; stats.total++; } diff --git a/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/store.js b/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/store.js index 619c855e0..5a07bf255 100644 --- a/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/store.js +++ b/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/store.js @@ -25,7 +25,8 @@ export class Store { memoryStorage[name] = JSON.stringify(data); } - if (callback) callback(JSON.parse(memoryStorage[name])); + if (callback) + callback(JSON.parse(memoryStorage[name])); } /** @@ -42,14 +43,16 @@ export class Store { * }) */ find(query, callback) { - if (!callback) return; + if (!callback) + return; const { todos } = JSON.parse(memoryStorage[this._dbName]); callback( todos.filter((todo) => { for (let q in query) { - if (query[q] !== todo[q]) return false; + if (query[q] !== todo[q]) + return false; } return true; @@ -63,7 +66,8 @@ export class Store { * @param {function} callback The callback to fire upon retrieving data */ findAll(callback) { - if (!callback) return; + if (!callback) + return; callback(JSON.parse(memoryStorage[this._dbName]).todos); } @@ -84,7 +88,8 @@ export class Store { if (id) { for (let i = 0; i < todos.length; i++) { if (todos[i].id === id) { - for (let key in updateData) todos[i][key] = updateData[key]; + for (let key in updateData) + todos[i][key] = updateData[key]; break; } @@ -92,7 +97,8 @@ export class Store { memoryStorage[this._dbName] = JSON.stringify(data); - if (callback) callback(JSON.parse(memoryStorage[this._dbName]).todos); + if (callback) + callback(JSON.parse(memoryStorage[this._dbName]).todos); } else { // Generate an ID updateData.id = uniqueID++; @@ -100,7 +106,8 @@ export class Store { todos.push(updateData); memoryStorage[this._dbName] = JSON.stringify(data); - if (callback) callback([updateData]); + if (callback) + callback([updateData]); } } @@ -123,7 +130,8 @@ export class Store { memoryStorage[this._dbName] = JSON.stringify(data); - if (callback) callback(JSON.parse(memoryStorage[this._dbName]).todos); + if (callback) + callback(JSON.parse(memoryStorage[this._dbName]).todos); } /** @@ -134,7 +142,8 @@ export class Store { drop(callback) { memoryStorage[this._dbName] = JSON.stringify({ todos: [] }); - if (callback) callback(JSON.parse(memoryStorage[this._dbName]).todos); + if (callback) + callback(JSON.parse(memoryStorage[this._dbName]).todos); } } diff --git a/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/template.js b/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/template.js index 0f681a6a9..7977d5133 100644 --- a/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/template.js +++ b/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/template.js @@ -12,7 +12,7 @@ const htmlEscapes = { const reUnescapedHtml = /[&<>"'`]/g; const reHasUnescapedHtml = new RegExp(reUnescapedHtml.source); -const escape = (str) => (str && reHasUnescapedHtml.test(str) ? str.replace(reUnescapedHtml, escapeHtmlChar) : str); +const escape = (str) => str && reHasUnescapedHtml.test(str) ? str.replace(reUnescapedHtml, escapeHtmlChar) : str; const escapeHtmlChar = (chr) => htmlEscapes[chr]; const createTodoItem = ({ id, title, completed, checked, index }) => ` diff --git a/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/view.js b/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/view.js index 82d347145..f5ba496a0 100644 --- a/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/view.js +++ b/resources/todomvc/vanilla-examples/javascript-es6-webpack/src/view.js @@ -12,7 +12,8 @@ const _setFilter = (currentPage) => { const _elementComplete = (id, completed) => { const listItem = qs(`[data-id="${id}"]`); - if (!listItem) return; + if (!listItem) + return; listItem.className = completed ? "completed" : ""; @@ -23,7 +24,8 @@ const _elementComplete = (id, completed) => { const _editItem = (id, title) => { const listItem = qs(`[data-id="${id}"]`); - if (!listItem) return; + if (!listItem) + return; listItem.className = `${listItem.className} editing`; @@ -38,7 +40,8 @@ const _editItem = (id, title) => { const _editItemDone = (id, title) => { const listItem = qs(`[data-id="${id}"]`); - if (!listItem) return; + if (!listItem) + return; const input = qs("input.edit", listItem); listItem.removeChild(input); @@ -58,7 +61,8 @@ const _itemId = (element) => { const _removeItem = (id, list) => { const elem = qs(`[data-id="${id}"]`); - if (elem) list.removeChild(elem); + if (elem) + list.removeChild(elem); }; /** @@ -164,7 +168,8 @@ export default class View { } }); $delegate(this.$todoList, "li .edit", "keypress", function (e) { - if (e.keyCode === ENTER_KEY) e.target.blur(); + if (e.keyCode === ENTER_KEY) + e.target.blur(); }); break; case "itemEditCancel": diff --git a/resources/todomvc/vanilla-examples/javascript-web-components/scripts/build.js b/resources/todomvc/vanilla-examples/javascript-web-components/scripts/build.js index 9ebebf888..d5fa77557 100644 --- a/resources/todomvc/vanilla-examples/javascript-web-components/scripts/build.js +++ b/resources/todomvc/vanilla-examples/javascript-web-components/scripts/build.js @@ -42,7 +42,8 @@ const copy = async (src, dest) => { }; const copyFilesToMove = async (files) => { - for (let i = 0; i < files.length; i++) await copy(files[i].src, `${targetDirectory}/${files[i].dest}`); + for (let i = 0; i < files.length; i++) + await copy(files[i].src, `${targetDirectory}/${files[i].dest}`); }; const updateImports = async ({ file, src, dest }) => { @@ -60,18 +61,21 @@ const build = async () => { // copy src folder await fs.cp(sourceDirectory, targetDirectory, { recursive: true }, (err) => { - if (err) console.error(err); + if (err) + console.error(err); }); // copy files to Move - for (const key in filesToMove) copyFilesToMove(filesToMove[key]); + for (const key in filesToMove) + copyFilesToMove(filesToMove[key]); // read html file let contents = await fs.readFile(`${rootDirectory}/${htmlFile}`, "utf8"); // remove base paths from files to move const filesToMoveForIndex = filesToMove.index; - for (let i = 0; i < filesToMoveForIndex.length; i++) contents = contents.replace(filesToMoveForIndex[i].src, filesToMoveForIndex[i].dest); + for (let i = 0; i < filesToMoveForIndex.length; i++) + contents = contents.replace(filesToMoveForIndex[i].src, filesToMoveForIndex[i].dest); // remove basePath from source directory const basePath = `${sourceDirectory.split("/")[1]}/`; diff --git a/resources/todomvc/vanilla-examples/javascript-web-components/src/components/todo-app/todo-app.component.js b/resources/todomvc/vanilla-examples/javascript-web-components/src/components/todo-app/todo-app.component.js index 8418c88b0..691980f3e 100644 --- a/resources/todomvc/vanilla-examples/javascript-web-components/src/components/todo-app/todo-app.component.js +++ b/resources/todomvc/vanilla-examples/javascript-web-components/src/components/todo-app/todo-app.component.js @@ -51,7 +51,8 @@ class TodoApp extends HTMLElement { toggleItem(event) { this.#data.forEach((entry) => { - if (entry.id === event.detail.id) entry.completed = event.detail.completed; + if (entry.id === event.detail.id) + entry.completed = event.detail.completed; }); this.update("toggle-item", event.detail.id); @@ -59,7 +60,8 @@ class TodoApp extends HTMLElement { removeItem(event) { this.#data.forEach((entry, index) => { - if (entry.id === event.detail.id) this.#data.splice(index, 1); + if (entry.id === event.detail.id) + this.#data.splice(index, 1); }); this.update("remove-item", event.detail.id); @@ -67,7 +69,8 @@ class TodoApp extends HTMLElement { updateItem(event) { this.#data.forEach((entry) => { - if (entry.id === event.detail.id) entry.title = event.detail.title; + if (entry.id === event.detail.id) + entry.title = event.detail.title; }); this.update("update-item", event.detail.id); diff --git a/resources/todomvc/vanilla-examples/javascript-web-components/src/components/todo-bottombar/todo-bottombar.component.js b/resources/todomvc/vanilla-examples/javascript-web-components/src/components/todo-bottombar/todo-bottombar.component.js index 0c73cb291..f5b8896c5 100644 --- a/resources/todomvc/vanilla-examples/javascript-web-components/src/components/todo-bottombar/todo-bottombar.component.js +++ b/resources/todomvc/vanilla-examples/javascript-web-components/src/components/todo-bottombar/todo-bottombar.component.js @@ -27,16 +27,20 @@ class TodoBottombar extends HTMLElement { } updateDisplay() { - if (parseInt(this["total-items"]) !== 0) this.element.style.display = "block"; - else this.element.style.display = "none"; + if (parseInt(this["total-items"]) !== 0) + this.element.style.display = "block"; + else + this.element.style.display = "none"; this.todoStatus.textContent = `${this["active-items"]} ${this["active-items"] === "1" ? "item" : "items"} left!`; } updateRoute(route) { this.filterLinks.forEach((link) => { - if (link.dataset.route === route) link.classList.add("selected"); - else link.classList.remove("selected"); + if (link.dataset.route === route) + link.classList.add("selected"); + else + link.classList.remove("selected"); }); } @@ -53,10 +57,12 @@ class TodoBottombar extends HTMLElement { } attributeChangedCallback(property, oldValue, newValue) { - if (oldValue === newValue) return; + if (oldValue === newValue) + return; this[property] = newValue; - if (this.isConnected) this.updateDisplay(); + if (this.isConnected) + this.updateDisplay(); } connectedCallback() { diff --git a/resources/todomvc/vanilla-examples/javascript-web-components/src/components/todo-item/todo-item.component.js b/resources/todomvc/vanilla-examples/javascript-web-components/src/components/todo-item/todo-item.component.js index 13c255c18..7a310bf82 100644 --- a/resources/todomvc/vanilla-examples/javascript-web-components/src/components/todo-item/todo-item.component.js +++ b/resources/todomvc/vanilla-examples/javascript-web-components/src/components/todo-item/todo-item.component.js @@ -55,7 +55,8 @@ class TodoItem extends HTMLElement { args.forEach((argument) => { switch (argument) { case "itemid": - if (this.itemid !== undefined) this.item.id = `todo-item-${this.itemid}`; + if (this.itemid !== undefined) + this.item.id = `todo-item-${this.itemid}`; break; case "itemtitle": if (this.itemtitle !== undefined) { @@ -146,10 +147,12 @@ class TodoItem extends HTMLElement { } attributeChangedCallback(property, oldValue, newValue) { - if (oldValue === newValue) return; + if (oldValue === newValue) + return; this[property] = newValue; - if (this.isConnected) this.update(property); + if (this.isConnected) + this.update(property); } connectedCallback() { diff --git a/resources/todomvc/vanilla-examples/javascript-web-components/src/components/todo-list/todo-list.component.js b/resources/todomvc/vanilla-examples/javascript-web-components/src/components/todo-list/todo-list.component.js index 366169de3..766f4124b 100644 --- a/resources/todomvc/vanilla-examples/javascript-web-components/src/components/todo-list/todo-list.component.js +++ b/resources/todomvc/vanilla-examples/javascript-web-components/src/components/todo-list/todo-list.component.js @@ -52,7 +52,8 @@ class TodoList extends HTMLElement { removeCompletedItems() { this.#elements = this.#elements.filter((element) => { - if (element.itemcompleted === "true") element.removeItem(); + if (element.itemcompleted === "true") + element.removeItem(); return element.itemcompleted === "false"; }); @@ -60,14 +61,18 @@ class TodoList extends HTMLElement { toggleItems(completed) { this.#elements.forEach((element) => { - if (completed && element.itemcompleted === "false") element.toggleInput.click(); - else if (!completed && element.itemcompleted === "true") element.toggleInput.click(); + if (completed && element.itemcompleted === "false") + element.toggleInput.click(); + else if (!completed && element.itemcompleted === "true") + element.toggleInput.click(); }); } updateStyles() { - if (parseInt(this["total-items"]) !== 0) this.listNode.style.display = "block"; - else this.listNode.style.display = "none"; + if (parseInt(this["total-items"]) !== 0) + this.listNode.style.display = "block"; + else + this.listNode.style.display = "none"; } updateView(element) { @@ -91,7 +96,8 @@ class TodoList extends HTMLElement { case "toggle-item": case "add-item": this.#elements.forEach((element) => { - if (element.itemid === id) this.updateView(element); + if (element.itemid === id) + this.updateView(element); }); break; case "remove-item": @@ -106,9 +112,11 @@ class TodoList extends HTMLElement { } attributeChangedCallback(property, oldValue, newValue) { - if (oldValue === newValue) return; + if (oldValue === newValue) + return; this[property] = newValue; - if (this.isConnected) this.updateStyles(); + if (this.isConnected) + this.updateStyles(); } connectedCallback() { diff --git a/resources/todomvc/vanilla-examples/javascript-web-components/src/components/todo-topbar/todo-topbar.component.js b/resources/todomvc/vanilla-examples/javascript-web-components/src/components/todo-topbar/todo-topbar.component.js index 5abc024c9..973fb0614 100644 --- a/resources/todomvc/vanilla-examples/javascript-web-components/src/components/todo-topbar/todo-topbar.component.js +++ b/resources/todomvc/vanilla-examples/javascript-web-components/src/components/todo-topbar/todo-topbar.component.js @@ -41,7 +41,8 @@ class TodoTopbar extends HTMLElement { } addItem(event) { - if (!event.target.value.length) return; + if (!event.target.value.length) + return; this.dispatchEvent( new CustomEvent("add-item", { @@ -95,10 +96,12 @@ class TodoTopbar extends HTMLElement { } attributeChangedCallback(property, oldValue, newValue) { - if (oldValue === newValue) return; + if (oldValue === newValue) + return; this[property] = newValue; - if (this.isConnected) this.updateDisplay(); + if (this.isConnected) + this.updateDisplay(); } connectedCallback() { diff --git a/resources/todomvc/vanilla-examples/javascript-web-components/src/hooks/useDoubleClick.js b/resources/todomvc/vanilla-examples/javascript-web-components/src/hooks/useDoubleClick.js index 94e4a7d6a..a1fe952fe 100644 --- a/resources/todomvc/vanilla-examples/javascript-web-components/src/hooks/useDoubleClick.js +++ b/resources/todomvc/vanilla-examples/javascript-web-components/src/hooks/useDoubleClick.js @@ -11,7 +11,8 @@ export function useDoubleClick(fn, delay) { return function (...args) { const now = new Date().getTime(); const difference = now - last; - if (difference < delay && difference > 0) fn.apply(this, args); + if (difference < delay && difference > 0) + fn.apply(this, args); last = now; }; diff --git a/resources/todomvc/vanilla-examples/javascript-web-components/src/hooks/useKeyListener.js b/resources/todomvc/vanilla-examples/javascript-web-components/src/hooks/useKeyListener.js index 30196c960..453747d54 100644 --- a/resources/todomvc/vanilla-examples/javascript-web-components/src/hooks/useKeyListener.js +++ b/resources/todomvc/vanilla-examples/javascript-web-components/src/hooks/useKeyListener.js @@ -3,7 +3,8 @@ export function useKeyListener(props) { function handleEvent(event) { Object.keys(callbacks).forEach((key) => { - if (event.key === key) callbacks[key](event); + if (event.key === key) + callbacks[key](event); }); } diff --git a/resources/todomvc/vanilla-examples/javascript-web-components/src/hooks/useRouter.js b/resources/todomvc/vanilla-examples/javascript-web-components/src/hooks/useRouter.js index 5b02573ec..ab1ab618a 100644 --- a/resources/todomvc/vanilla-examples/javascript-web-components/src/hooks/useRouter.js +++ b/resources/todomvc/vanilla-examples/javascript-web-components/src/hooks/useRouter.js @@ -14,7 +14,8 @@ export const useRouter = (callback) => { const handleChange = () => { current = document.location.hash; /* istanbul ignore else */ - if (onChange) onChange(document.location.hash); + if (onChange) + onChange(document.location.hash); }; /** diff --git a/tests/benchmark-runner-tests.mjs b/tests/benchmark-runner-tests.mjs index 8e127918d..449ceb266 100644 --- a/tests/benchmark-runner-tests.mjs +++ b/tests/benchmark-runner-tests.mjs @@ -119,7 +119,8 @@ describe("BenchmarkRunner", () => { _loadFrameStub = stub(SuiteRunner.prototype, "_loadFrame").callsFake(async () => null); _appendFrameStub = stub(runner, "_appendFrame").callsFake(async () => null); _removeFrameStub = stub(runner, "_removeFrame").callsFake(() => null); - for (const suite of runner._suites) spy(suite, "prepare"); + for (const suite of runner._suites) + spy(suite, "prepare"); expect(runner._suites).not.to.have.length(0); await runner.runAllSuites(); }); diff --git a/tests/run.mjs b/tests/run.mjs index adde75d90..8d3461d09 100644 --- a/tests/run.mjs +++ b/tests/run.mjs @@ -35,10 +35,12 @@ function printHelp(message = "") { const options = commandLineArgs(optionDefinitions); -if ("help" in options) printHelp(); +if ("help" in options) + printHelp(); const BROWSER = options?.browser; -if (!BROWSER) printHelp("No browser specified, use $BROWSER or --browser"); +if (!BROWSER) + printHelp("No browser specified, use $BROWSER or --browser"); let capabilities; switch (BROWSER) { diff --git a/tests/server.mjs b/tests/server.mjs index 0dea2e4ce..0b209b897 100644 --- a/tests/server.mjs +++ b/tests/server.mjs @@ -19,11 +19,13 @@ const STATIC_PATH = path.join(process.cwd(), "./"); const toBool = [() => true, () => false]; export default function serve(port) { - if (!port) throw new Error("Port is required"); + if (!port) + throw new Error("Port is required"); const prepareFile = async (url) => { const paths = [STATIC_PATH, url]; - if (url.endsWith("/")) paths.push("index.html"); + if (url.endsWith("/")) + paths.push("index.html"); const filePath = path.join(...paths); const pathTraversal = !filePath.startsWith(STATIC_PATH); const exists = await fs.promises.access(filePath).then(...toBool); From 579410943f4a841da32b7312e10f0049b1587ba6 Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Tue, 7 Jan 2025 10:04:48 +0100 Subject: [PATCH 04/11] cleanup --- README.md | 20 ++++ about.html | 235 --------------------------------------------- resources/main.css | 43 +-------- 3 files changed, 24 insertions(+), 274 deletions(-) diff --git a/README.md b/README.md index 031b2f01f..fd277c863 100644 --- a/README.md +++ b/README.md @@ -14,3 +14,23 @@ benchmark, actual users should benefit. In order to achieve this, it should: - Be accessible to the public and useful to browser engineers. It should run in every modern browser by visiting a normal web page. It should run relatively quickly, while providing enough test coverage to be reflective of the real-world Web. + + +# Sore and Test Measurement + +Each test can contain several steps who contributed to the test duration. Note that the prepare step of a test is *unmeasured* and thus does not contribute to the score. All following test +steps are **measured** and summed up in the test step time. + + + + +Each step consists of the following phases: +
    +
    Sync:
    +
    Time spent in synchronous JS execution.
    +
    Async:
    +
    Time spent in asynchronous JS like Promise or setTimeout tasks scheduled by the sync-step.
    +
    + + +The final benchmark score is calculated based of the inverse of [geomean](https://en.wikipedia.org/wiki/Geometric_mean) of all tests. We average the score over multiple iterations with the [arithmetic mean](https://en.wikipedia.org/wiki/Arithmetic_mean). By using the geomean to combine the test durations we maintain the invariant that relative improvements are favoured equally amongst all tests, even though they can have vastly different durations. \ No newline at end of file diff --git a/about.html b/about.html index cf68747e4..77f1c2933 100644 --- a/about.html +++ b/about.html @@ -91,241 +91,6 @@

    About Speedometer 3

    built as static files ahead of time. - -

    Score and Test Measurement

    -

    - Each test can contain several steps who contributed to the test duration. Note that the prepare step of a test is unmeasured and thus does not contribute to the score. All following test - steps are measured and summed up in the test step time. -

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Iteration:Iteration 1...Iteration N
    Test:TodoMVC-JavaScript-ES5...Perf-DashboardTodoMVC-......
    Steps:PrepareAddingCompleting...Prepare...Prepare...
    SyncAsyncSyncAsync
    -

    Each step consists of the following phases:

    -
    -
    Sync:
    -
    Time spent in synchronous JS execution.
    -
    Async:
    -
    Time spent in asynchronous JS like Promise or setTimeout tasks scheduled by the sync-step.
    -
    -

    - The final benchmark score is calculated based of the inverse of geomean of all tests. We average the score over multiple iterations with the - arithmetic mean. By using the geomean to combine the test durations we maintain the invariant that relative improvements are favoured equally amongst all tests, - even though they can have vastly different durations. -

    -

    - - - - - - Score - - - - - = - - 1 - n - - - - - - i - = - 1 - - n - - - - - IterationScore - - i - - - - - - - - - IterationScore - - i - - - - - = - - 1000 - - - IterationGeoMeanTime - - i - - - - - - - - - - IterationGeoMeanTime - - i - - - - - = - - - - - - - j - = - 1 - - m - - - - - TestTime - - - i - j - - - - m - - - - - - - - - TestTime - - - i - j - - - - - - = - - - - k - - - - - TestStepTime - - - i - j - k - - - - - - - - - - TestStepTime - - - i - j - k - - - - - - = - - - TestStepSyncTime - - - i - j - k - - - + - - - TestStepAsyncTime - - - i - j - k - - - - - - - -