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

Function prettyMilliseconds

frontend/src/utils/utils.ts:552–589  ·  view source on GitHub ↗
(
  n: number | string,
  options?: prettyMillisecondsOriginal.Options & PrettyValueOptions
)

Source from the content-addressed store, hash-verified

550};
551
552export const prettyMilliseconds = (
553 n: number | string,
554 options?: prettyMillisecondsOriginal.Options & PrettyValueOptions
555) => {
556 if (typeof n === 'undefined' || n === null) {
557 return options?.showNullAs ?? 'N/A'; // null, undefined -> N/A
558 }
559
560 if (options?.showLargeAsInfinite && isUInt64Maximum(String(n))) {
561 return 'Infinite';
562 }
563
564 if (typeof n !== 'number') {
565 if (typeof n === 'string') {
566 // string
567 if (n === '') {
568 return 'N/A'; // empty -> N/A
569 }
570
571 const parsed = Number.parseFloat(String(n));
572
573 if (!Number.isFinite(parsed)) {
574 return String(parsed); // "NaN" or "Infinity"
575 }
576
577 // number parsed, fall through
578 return prettyMillisecondsOriginal(parsed, options);
579 }
580 // something else: object, function, ...
581 return 'NaN';
582 }
583 if (!Number.isFinite(n)) {
584 return 'N/A';
585 }
586
587 // n is a finite number
588 return prettyMillisecondsOriginal(n, options);
589};
590
591const ONE_THOUSAND = 1000;
592const ONE_MILLION = 1_000_000;

Callers 9

RetentionTimeSelectFunction · 0.90
RetentionTimeSelectFunction · 0.90
TopicMessageViewFunction · 0.90
summaryMethod · 0.90
renderMethod · 0.90
DataRefreshButtonFunction · 0.90
TimestampDisplayFunction · 0.90
formatConfigValueFunction · 0.90

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…