@quantumwake/terminal-ux-dashboard-components 0.1.30 → 0.1.32

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.
package/dist/index.d.cts CHANGED
@@ -249,10 +249,11 @@ declare const groupBy: (records: Row[], column: string) => Record<string, Row[]>
249
249
  declare const aggregate: (records: Row[], column: string, fn: AggFn | string) => number;
250
250
 
251
251
  /**
252
- * Formats a byte count as a human-readable string: plain bytes under 1024
253
- * ("999 B"), then KB/MB/GB/TB with one decimal place ("1.0 KB", "1.5 MB",
254
- * "2.0 GB"), capped at TB (no PB+). `perSecond` appends "/s" — for
255
- * throughput series (KB/s, MB/s, GB/s).
252
+ * Formats a byte count as a human-readable string: plain bytes under 1000
253
+ * ("999 B"), then KB/MB/GB/TB/PB with one decimal place ("1.0 KB", "1.5 MB",
254
+ * "2.0 GB"). Uses decimal (SI, base-1000) units, as the product lists them
255
+ * ("B / KB / MB / GB / TB / PB") — not KiB/MiB binary units. `perSecond`
256
+ * appends "/s" — for throughput series (KB/s, MB/s, GB/s).
256
257
  */
257
258
  declare function formatBytes(value: number, perSecond?: boolean): string;
258
259
 
package/dist/index.d.ts CHANGED
@@ -249,10 +249,11 @@ declare const groupBy: (records: Row[], column: string) => Record<string, Row[]>
249
249
  declare const aggregate: (records: Row[], column: string, fn: AggFn | string) => number;
250
250
 
251
251
  /**
252
- * Formats a byte count as a human-readable string: plain bytes under 1024
253
- * ("999 B"), then KB/MB/GB/TB with one decimal place ("1.0 KB", "1.5 MB",
254
- * "2.0 GB"), capped at TB (no PB+). `perSecond` appends "/s" — for
255
- * throughput series (KB/s, MB/s, GB/s).
252
+ * Formats a byte count as a human-readable string: plain bytes under 1000
253
+ * ("999 B"), then KB/MB/GB/TB/PB with one decimal place ("1.0 KB", "1.5 MB",
254
+ * "2.0 GB"). Uses decimal (SI, base-1000) units, as the product lists them
255
+ * ("B / KB / MB / GB / TB / PB") — not KiB/MiB binary units. `perSecond`
256
+ * appends "/s" — for throughput series (KB/s, MB/s, GB/s).
256
257
  */
257
258
  declare function formatBytes(value: number, perSecond?: boolean): string;
258
259
 
package/dist/index.js CHANGED
@@ -430,17 +430,21 @@ var aggregate = (records, column, fn) => {
430
430
  };
431
431
 
432
432
  // src/format.ts
433
- var BYTE_UNITS = ["KB", "MB", "GB", "TB"];
433
+ var BYTE_UNITS = ["KB", "MB", "GB", "TB", "PB"];
434
434
  function formatBytes(value, perSecond = false) {
435
435
  const suffix = perSecond ? "/s" : "";
436
436
  if (!Number.isFinite(value)) return `\u2014 B${suffix}`;
437
437
  const sign = value < 0 ? "-" : "";
438
438
  const abs = Math.abs(value);
439
- if (abs < 1024) return `${sign}${Math.round(abs)} B${suffix}`;
440
- let scaled = abs / 1024;
439
+ if (abs < 1e3) return `${sign}${Math.round(abs)} B${suffix}`;
440
+ let scaled = abs / 1e3;
441
441
  let unit = 0;
442
- while (scaled >= 1024 && unit < BYTE_UNITS.length - 1) {
443
- scaled /= 1024;
442
+ while (scaled >= 1e3 && unit < BYTE_UNITS.length - 1) {
443
+ scaled /= 1e3;
444
+ unit++;
445
+ }
446
+ if (scaled.toFixed(1) === "1000.0" && unit < BYTE_UNITS.length - 1) {
447
+ scaled /= 1e3;
444
448
  unit++;
445
449
  }
446
450
  return `${sign}${scaled.toFixed(1)} ${BYTE_UNITS[unit]}${suffix}`;