@nbxx/nb-input
Version:
Angular - nbinput
27 lines • 891 B
JavaScript
import { Pipe } from '@angular/core';
import { DecimalPipe } from '@angular/common';
export class NbinputFilesizePipe {
constructor(number) {
this.number = number;
}
transform(value, args) {
if (value > 1073741824) {
return this.number.transform(value / 1073741824, '1.0-2') + 'G';
}
else if (value > 1048576) {
return this.number.transform(value / 1048576, '1.0-2') + 'M';
}
else if (value > 1024) {
return this.number.transform(value / 1024, '1.0-2') + 'K';
}
return this.number.transform(value, '1.0-2') + 'B';
}
}
NbinputFilesizePipe.decorators = [
{ type: Pipe, args: [{ name: 'filesize' },] },
];
/** @nocollapse */
NbinputFilesizePipe.ctorParameters = () => [
{ type: DecimalPipe }
];
//# sourceMappingURL=nbinput-filesize.pipe.js.map