UNPKG

@c8y/ngx-components

Version:

Angular modules for Cumulocity IoT applications

40 lines 1.76 kB
import { PipeTransform } from '@angular/core'; import { TranslateService } from '@ngx-translate/core'; import * as i0 from "@angular/core"; interface BytesOptions { precision?: number; binary?: boolean; } /** * Converts the file size to a readable format. * Supports both decimal (default) and binary units. * * Usage: * ```html * {{ myData | bytes }} <!-- e.g. 100.1 MB (decimal) --> * {{ myData | bytes:2 }} <!-- e.g. 100.12 MB (decimal) --> * {{ myData | bytes:1:true }} <!-- e.g. 97.7 MiB (binary) --> * {{ myData | bytes:{binary: true} }} <!-- e.g. 97.7 MiB (binary) --> * {{ myData | bytes:{precision: 2, binary: true} }} <!-- e.g. 97.66 MiB (binary) --> * ``` * * @param value The number of bytes to convert * @param precisionOrOptions Number of decimal places or options object * @param binary Whether to use binary (1024) or decimal (1000) units (legacy parameter) * * Options object properties: * - precision: number of decimal places (default: 1) * - binary: whether to use binary units (default: false) * * Decimal units: bytes, kB, MB, GB, TB, PB * Binary units: bytes, KiB, MiB, GiB, TiB, PiB */ export declare class BytesPipe implements PipeTransform { static bytes(bytes: number, precisionOrOptions?: number | BytesOptions, binary?: boolean, translateService?: TranslateService): string | number; private translateService; transform(value: number, precisionOrOptions?: number | BytesOptions, binary?: boolean): string | number; static ɵfac: i0.ɵɵFactoryDeclaration<BytesPipe, never>; static ɵpipe: i0.ɵɵPipeDeclaration<BytesPipe, "bytes", true>; } export {}; //# sourceMappingURL=bytes.pipe.d.ts.map