chore: trim excessive comments

This commit is contained in:
wonfen
2026-08-19 07:27:43 +08:00
parent 42b91b6294
commit 807f9a206d
103 changed files with 293 additions and 2517 deletions
-4
View File
@@ -47,10 +47,6 @@ const computeDebugEnabled = (): boolean => {
const isDebugLoggingEnabled = () =>
cachedDebugEnabled ?? (cachedDebugEnabled = computeDebugEnabled())
/**
* Logs to the console only when debug logging is enabled.
* Forwards all arguments to `console.log`; does nothing otherwise.
*/
export const debugLog = (...args: any[]) => {
if (!isDebugLoggingEnabled()) return
console.log(...args)
+2 -25
View File
@@ -1,23 +1,9 @@
/**
* What a delay number means, before anyone decides how to draw it.
*
* The core reports latency through a single number that encodes several non-measurements:
* sentinels for "never tested" and "testing now", zero and large values for timeouts, and
* absurd values for errors. Every surface agreed on those rules and restated them; they are
* stated once here.
*
* How a *measured* delay is graded — fast, slow, and the thresholds between — is deliberately
* not here. A three-colour chip and a four-bar signal icon draw different distinctions, and
* flattening them would be inventing a UI decision rather than removing a duplicate one.
*/
/** Normalizes latency values and the core's non-measurement sentinels. */
/** The delay above which the core is considered to have timed out. */
export const DEFAULT_DELAY_TIMEOUT = 10000
/** The value the core reports for a node whose test is in flight. */
const TESTING = -2
/** Above this, the number is not a latency at all. */
const IMPLAUSIBLE_DELAY = 1e5
export type DelayState =
@@ -25,7 +11,6 @@ export type DelayState =
| 'untested'
| 'error'
| 'timeout'
/** An actual latency measurement, in milliseconds. */
| 'measured'
export const classifyDelay = (
@@ -40,13 +25,7 @@ export const classifyDelay = (
return 'measured'
}
/**
* The order delays sort in: measured first and fastest first, then timeouts, then errors,
* then everything we have no measurement for.
*
* Ranks are compared before values so that a non-measurement can never sort ahead of a real
* one just because its sentinel happens to be a small number.
*/
/** Rank separately so sentinel magnitudes cannot outrank real measurements. */
const rankOf = (state: DelayState): number => {
switch (state) {
case 'measured':
@@ -62,7 +41,6 @@ const rankOf = (state: DelayState): number => {
}
}
/** A total order over delays, for sorting a proxy list fastest-first. */
export const compareByDelay = (
a: number,
b: number,
@@ -75,7 +53,6 @@ export const compareByDelay = (
const rankDifference = rankOf(aState) - rankOf(bState)
if (rankDifference !== 0) return rankDifference
// Within a rank, only a real measurement has a meaningful magnitude.
if (aState !== 'measured') return 0
return a - b
}