Compare commits

...

1 Commits

Author SHA1 Message Date
Thierry
2243805d01 feat(lite): enhance human-format TypeScript Definition file 2023-03-22 16:58:05 +01:00

View File

@@ -1,16 +1,90 @@
declare module "human-format" {
type Options = {
decimals?: number;
maxDecimals?: number;
prefix?: string;
scale?: string;
type BinaryPrefix =
| ""
| "Ki"
| "Mi"
| "Gi"
| "Ti"
| "Pi"
| "Ei"
| "Zi"
| "Yi";
type SIPrefix =
| "y"
| "z"
| "a"
| "f"
| "p"
| "n"
| "µ"
| "m"
| ""
| "k"
| "M"
| "G"
| "T"
| "P"
| "E"
| "Z"
| "Y";
type ScaleName = "binary" | "SI";
type Prefix<S extends ScaleName> = S extends "binary"
? BinaryPrefix
: SIPrefix;
interface Options<S extends ScaleName> {
maxDecimals?: number | "auto";
separator?: string;
unit?: string;
};
scale?: S;
strict?: boolean;
prefix?: Prefix<S>;
decimals?: number;
}
function humanFormat(value: number, opts?: Options): number;
function bytes(value: number): number;
interface Info<S extends ScaleName> {
value: number;
prefix: Prefix<S>;
unit?: string;
}
humanFormat.bytes = bytes;
export default humanFormat;
interface ParsedInfo<S extends ScaleName> {
value: number;
factor: number;
prefix: Prefix<S>;
unit?: string;
}
function humanFormat<S extends ScaleName>(
value: number,
opts?: Options<S>
): string;
namespace humanFormat {
function bytes<S extends ScaleName>(
value: number,
opts?: Options<S>
): string;
function parse<S extends ScaleName>(str: string, opts?: Options<S>): number;
namespace parse {
function raw<S extends ScaleName>(
str: string,
opts?: Options<S>
): ParsedInfo<S>;
}
function raw<S extends ScaleName>(
value: number,
opts?: Options<S>
): Info<S>;
export { bytes, parse, raw, Prefix, BinaryPrefix };
}
export = humanFormat;
}