MCPcopy
hub / github.com/redpanda-data/console / prettyBytes

Function prettyBytes

frontend/src/utils/utils.ts:519–550  ·  view source on GitHub ↗
(n: number | string | null | undefined, options?: PrettyValueOptions)

Source from the content-addressed store, hash-verified

517}
518
519export const prettyBytes = (n: number | string | null | undefined, options?: PrettyValueOptions) => {
520 if (typeof n === 'undefined' || n === null) {
521 return options?.showNullAs ?? 'N/A'; // null, undefined -> N/A
522 }
523
524 if (options?.showLargeAsInfinite && isUInt64Maximum(String(n))) {
525 return 'Infinite';
526 }
527
528 if (typeof n !== 'number') {
529 if (typeof n === 'string') {
530 // string
531 if (n === '') {
532 return 'N/A'; // empty -> N/A
533 }
534
535 const parsed = Number.parseFloat(String(n));
536
537 if (!Number.isFinite(parsed)) {
538 return String(parsed); // "NaN" or "Infinity"
539 }
540
541 // number parsed, fall through
542 return prettyBytesOriginal(parsed, { binary: true });
543 }
544 // something else: object, function, ...
545 return 'NaN';
546 }
547
548 // n is a finite number
549 return prettyBytesOriginal(n, { binary: true });
550};
551
552export const prettyMilliseconds = (
553 n: number | string,

Callers 12

RetentionSizeSelectFunction · 0.90
RetentionSizeSelectFunction · 0.90
TopicMessageViewFunction · 0.90
MessageKeyPreviewFunction · 0.90
MessageMetaDataFunction · 0.90
MessagePreviewFunction · 0.90
formatBytesFunction · 0.90
ToolEventCardFunction · 0.90
renderMethod · 0.90
LogExplorerFunction · 0.90
prettyBytesOrNAFunction · 0.85

Calls 2

isUInt64MaximumFunction · 0.85
StringInterface · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…