dsh-homepage 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -47,6 +47,10 @@
47
47
  * @returns e.g. `42%`, or an em dash when there is no reading.
48
48
  */
49
49
  function percent(ratio) {
50
+ // `Number(null)` is 0, so a missing reading would otherwise print as a
51
+ // real 0% — which a reader takes for an idle machine rather than a blind
52
+ // spot (macOS and Intel publish no GPU counter at all).
53
+ if (ratio === null || ratio === undefined) return '—'
50
54
  var value = Number(ratio)
51
55
  if (!isFinite(value)) return '—'
52
56
  return Math.round(Math.max(0, Math.min(1, value)) * 100) + '%'
@@ -234,13 +238,15 @@
234
238
  }
235
239
 
236
240
  /**
237
- * `used / total` when a total is known, else null — a row with no reading
238
- * must not claim `0 B / 0 B` in its tooltip.
241
+ * `used / total` when both are known, else null — a row with no reading
242
+ * must not claim `0 B / 0 B` in its tooltip, and a driver that names the
243
+ * card without publishing a counter must not claim `0 B` used either.
239
244
  * @param used - bytes used.
240
245
  * @param total - bytes total.
241
246
  * @returns the pair, or null.
242
247
  */
243
248
  function pairText(used, total) {
249
+ if (used === null || used === undefined) return null
244
250
  return Number(total) > 0 ? bytes(used) + ' / ' + bytes(total) : null
245
251
  }
246
252