MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / formatDownloadCount

Function formatDownloadCount

src/utils/helpers.js:514–528  ·  view source on GitHub ↗
(downloadCount)

Source from the content-addressed store, hash-verified

512 };
513 },
514 formatDownloadCount(downloadCount) {
515 const units = ["", "K", "M", "B", "T"];
516 let index = 0;
517
518 while (downloadCount >= 1000 && index < units.length - 1) {
519 downloadCount /= 1000;
520 index++;
521 }
522
523 const countStr =
524 downloadCount < 10 ? downloadCount.toFixed(2) : downloadCount.toFixed(1);
525 const trimmedCountStr = countStr.replace(/\.?0+$/, "");
526
527 return `${trimmedCountStr}${units[index]}`;
528 },
529 normalizeMtime(value) {
530 if (value == null) return null;
531 const time = value instanceof Date ? value.getTime() : Number(value);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected