Gathering detailed insights and metrics for angular-pretty-size
Gathering detailed insights and metrics for angular-pretty-size
npm install angular-pretty-size
Typescript
Module System
64.6
Supply Chain
95.4
Quality
75
Maintenance
100
Vulnerability
98.9
License
Total Downloads
2,148
Last Day
1
Last Week
3
Last Month
88
Last Year
242
Minified
Minified + Gzipped
Latest Version
0.0.3
Package Id
angular-pretty-size@0.0.3
Unpacked Size
15.42 kB
Size
4.74 kB
File Count
23
Cumulative downloads
Total Downloads
Last day
0%
1
Compared to previous day
Last week
-85%
3
Compared to previous week
Last month
450%
88
Compared to previous month
Last year
-6.2%
242
Compared to previous year
2
32
Angular library that converts bytes to a human readable string. 1189 to 1.2KB.
You can install this package locally with npm.
1# To get the latest stable version and update package.json file: 2npm install angular-pretty-size --save 3# or 4yarn add angular-pretty-size
After installing the library, import it in you module.
1import {PrettySizeModule} from 'angular-pretty-size'; 2 3// using default options 4@NgModule({ 5 imports: [ 6 // ... 7 PrettySizeModule 8 ] 9 //others 10})
Use it in html.
1//directive 2<nxt-pretty-size [size]="'1000'"></nxt-pretty-size> 3//pipe 4{{1000|nxtPrettySize}} 5//or 6<span [nxtPrettySize]="'1000'"></span>
Use service in your component.
1import {PrettySizeService} from 'angular-pretty-size'; 2 3export class TestComponent { 4 displaySize: string; 5 6 constructor(private prettySizeService: PrettySizeService) { 7 this.displaySize = this.prettySizeService.pretty(10178); 8 } 9}
Optionaly, PrettySizeModule can be configured by passing PrettySizeOptions to the forRoot
method of PrettySizeModule
.
PrettySizeOptions default options is.
1export class PrettySizeOptions { 2 units: string[] = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; //all units,length is 9 3 divisor: number = 1000; //1000 or 1024 4 scale: number = 1; //NumberObject.toFixed(scale) 5}
Make sure the units, divisor and scale is not empty.
As you can see, I added a space before each unit. 1024 bytes displayed as 10 KiB
.
1import {PrettySizeModule, PrettySizeOptions} from 'angular-pretty-size'; 2 3@NgModule({ 4 imports: [ 5 // make sure units,divisor and scale is not empty 6 PrettySizeModule.forRoot({ 7 provide: PrettySizeOptions, 8 useValue: { 9 units: [' Byte', ' KiB', ' MiB', ' GiB', ' TiB', ' PiB', ' EiB', ' ZiB', ' YiB'], 10 divisor: 1024, 11 scale: 1, // 0, 1 or 2 12 }, 13 }), 14 ] 15 //others 16})
No vulnerabilities found.
No security vulnerabilities found.