@ynmstudio/utils
Version:
YNM Utilities for Angular
28 lines (24 loc) • 1.23 kB
JavaScript
import * as i0 from '@angular/core';
import { Pipe } from '@angular/core';
import { isNumber } from '@ynmstudio/utils/helpers';
class FileSizePipe {
transform(bytes) {
const _bytes = bytes ? isNumber(bytes) ? bytes : parseInt(bytes) : 0;
if (_bytes === 0)
return '0 bytes';
const sizes = ['bytes', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
const i = Math.floor(Math.log(_bytes) / Math.log(1024));
return `${parseFloat((_bytes / Math.pow(1024, i)).toFixed(2))} ${sizes[i]}`;
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: FileSizePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.13", ngImport: i0, type: FileSizePipe, isStandalone: true, name: "fileSize" }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.13", ngImport: i0, type: FileSizePipe, decorators: [{
type: Pipe,
args: [{ name: 'fileSize' }]
}] });
/**
* Generated bundle index. Do not edit.
*/
export { FileSizePipe };
//# sourceMappingURL=ynmstudio-utils-pipes-file-size.mjs.map