RED-6830: File size format pipe
This commit is contained in:
parent
02d0089d0d
commit
aa4516286e
@ -2,3 +2,4 @@ export * from './log.pipe';
|
||||
export * from './humanize-camel-case.pipe';
|
||||
export * from './capitalize.pipe';
|
||||
export * from './humanize.pipe';
|
||||
export * from './size.pipe';
|
||||
|
||||
14
src/lib/pipes/size.pipe.ts
Normal file
14
src/lib/pipes/size.pipe.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import { Pipe, PipeTransform } from '@angular/core';
|
||||
|
||||
@Pipe({
|
||||
name: 'size',
|
||||
standalone: true,
|
||||
})
|
||||
export class SizePipe implements PipeTransform {
|
||||
transform(value: number): string {
|
||||
if (value >= 1000 ** 3) {
|
||||
return `${(value / 1000 ** 3).toFixed(2)} GB`;
|
||||
}
|
||||
return `${(value / 1000 ** 2).toFixed(2)} MB`;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user