@daiso-tech/core
Version:
The library offers flexible, framework-agnostic solutions for modern web applications, built on adaptable components that integrate seamlessly with popular frameworks like Next Js.
51 lines (50 loc) • 1.77 kB
TypeScript
/**
* @module FileSize
*/
import { type IFileSize, TO_BYTES } from "../../file-size/contracts/_module.js";
import { type ISerializable } from "../../serde/contracts/_module.js";
import { type IComparable } from "../../utilities/_module.js";
/**
* IMPORT_PATH: `"@daiso-tech/core/file-size"`
* @group Implementations
*/
export type SerializedFileSize = {
version: "1";
fileSizeInBytes: number;
};
/**
* The `FileSize` class is used for representing file size.
* `FileSize` class cannot be negative, if you pass negative number it will be converted to 0.
*
* IMPORT_PATH: `"@daiso-tech/core/file-size"`
* @group Implementations
*/
export declare class FileSize implements IFileSize, ISerializable<SerializedFileSize>, IComparable<IFileSize> {
private readonly fileSizeInBytes;
private static kbInBytes;
private static mbInBytes;
private static gbInBytes;
private static tbInBytes;
private static pbInBytes;
static deserialize(serializedValue: SerializedFileSize): FileSize;
static fromBytes(bytes: number): FileSize;
static fromKiloBytes(kiloBytes: number): FileSize;
static fromMegaBytes(megaBytes: number): FileSize;
static fromGigaBytes(gigaBytes: number): FileSize;
static fromTeraBytes(teraBytes: number): FileSize;
static fromPetaBytes(petaBytes: number): FileSize;
private constructor();
[TO_BYTES](): number;
equals(value: IFileSize): boolean;
gt(value: IFileSize): boolean;
gte(value: IFileSize): boolean;
lt(value: IFileSize): boolean;
lte(value: IFileSize): boolean;
serialize(): SerializedFileSize;
toBytes(): number;
toKiloBytes(): number;
toMegaBytes(): number;
toGigaBytes(): number;
toTeraBytes(): number;
toPetaBytes(): number;
}