22 lines
391 B
TypeScript
22 lines
391 B
TypeScript
/**
|
|
* MemoryDisplay
|
|
*
|
|
* Deterministic formatting for memory usage.
|
|
*/
|
|
|
|
export class MemoryFormatter {
|
|
/**
|
|
* Formats bytes as "123.4MB".
|
|
*/
|
|
static formatMB(bytes: number): string {
|
|
return `${(bytes / 1024 / 1024).toFixed(1)}MB`;
|
|
}
|
|
|
|
/**
|
|
* Formats bytes as "123.4KB".
|
|
*/
|
|
static formatKB(bytes: number): string {
|
|
return `${(bytes / 1024).toFixed(1)}KB`;
|
|
}
|
|
}
|