@demetra/file-size-pipe
v0.0.1
Published
`FileSizePipe` is an Angular pipe which can be used to format file size.
Downloads
2
Readme
UserBadge
FileSizePipe
is an Angular pipe which can be used to format file size.
{{ value_expression | filesize [ : precision ] }}
Installation
npm i @demetra/file-size-pipe
Usage
Once @demetra/file-size-pipe
is installed, your're ready to use it in your application.
Import FileSizePipeModule
into your application (ex. app.module.ts
):
import { FileSizePipeModule } from '@demetra/file-size-pipe';
// add it to your module imports
@NgModule({
imports: [
FileSizePipeModule
]
})
export class AppModule {}
Then use it in your templates:
{{ 513 | filesize }} <!-- Output: 513 B -->
{{ 1023 | filesize }} <!-- Output: 1023 B -->
{{ 1024 | filesize }} <!-- Output: 1 KB -->
{{ 389307.69555362803 | filesize }} <!-- Output: 380.2 KB -->
{{ 389307.69555362803 | filesize:3 }} <!-- Output: 380.183 KB -->
{{ 194877849.6 | filesize }} <!-- Output: 185.8 MB -->
{{ 445624331796.48 | filesize }} <!-- Output: 415 GB -->
{{ 922666177564508.1 | filesize }} <!-- Output: 839.2 TB -->
{{ 72552989996938690 | filesize }} <!-- Output: 64.4 PB -->
{{ 192272719323283880000 | filesize }} <!-- Output: 166.8 EB -->
{{ 9.271185997493831e+22 | filesize }} <!-- Output: 78.5 ZB -->
{{ 7.067743019213006e+26 | filesize }} <!-- Output: 584.6 YB -->
FileSizePipe
supportrs the following parameters:
| Parameter | Type | Description |
| ----------| ---- | ----------- |
| precision
| number
| Specify the precision to use for file size formatting (default: 1
) |