Skip to content

Commit

Permalink
Revert "Tweaking types and removing any usage"
Browse files Browse the repository at this point in the history
This reverts commit a3d0dd0.
  • Loading branch information
avoidwork committed Aug 10, 2023
1 parent 80dcac5 commit 3aee3e8
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 70 deletions.
33 changes: 18 additions & 15 deletions types/constants.d.ts
Expand Up @@ -19,20 +19,23 @@ export const SI_KBYTE: "kB";
export const SPACE: " ";
export const STRING: "string";
export const ZERO: "0";

export const STRINGS: {
symbol: {
iec: {
bits: string[],
bytes: string[]
},
jedec: {
bits: string[],
bytes: string[],
export namespace STRINGS {
namespace symbol {
namespace iec {
const bits: string[];
const bytes: string[];
}
},
fullform: {
iec: string[],
jedec: string[]
namespace jedec {
const bits_1: string[];
export { bits_1 as bits };
const bytes_1: string[];
export { bytes_1 as bytes };
}
}
namespace fullform {
const iec_1: string[];
export { iec_1 as iec };
const jedec_1: string[];
export { jedec_1 as jedec };
}
}
}
79 changes: 24 additions & 55 deletions types/filesize.d.ts
@@ -1,63 +1,32 @@
interface FileSizeOptionsBase {
base?: number;
export interface FileSizeOptions {
bits?: boolean;
exponent?: number;
fullform?: boolean;
fullforms?: string[];
locale?: string | boolean;
localeOptions?: Intl.DateTimeFormatOptions;
pad?: boolean;
precision?: number;
base?: number;
round?: number;
roundingMethod?: 'round' | 'floor' | 'ceil';
locale?: string;
localeOptions?: {};
separator?: string;
spacer?: string;
symbols?: {};
standard?: 'iec' | 'jedec';
symbols?: {
iec: {
bits: string[],
bytes: string[]
},
jedec: {
bits: string[],
bytes: string[]
}
};
}

interface FileSizeOptionsArray extends FileSizeOptionsBase {
output: 'array'
}

interface FileSizeOptionsExponent extends FileSizeOptionsBase {
output: 'exponent'
}

interface FileSizeOptionsObject extends FileSizeOptionsBase {
output: 'object'
}

interface FileSizeOptionsString extends FileSizeOptionsBase {
output: 'string'
}

interface FileSizeReturnObject {
value: string,
symbol: string,
exponent: number,
unit: string,
output?: 'array' | 'exponent' | 'object' | 'string';
fullform?: boolean;
fullforms?: any[];
exponent?: number;
roundingMethod?: 'round' | 'floor' | 'ceil';
precision?: number;
}

type FileSizeReturnArray = [ number, string ]

export function filesize(byteCount: number, options: FileSizeOptionsString): string
export function filesize(byteCount: number, options: FileSizeOptionsArray): FileSizeReturnArray
export function filesize(byteCount: number, options: FileSizeOptionsExponent): number
export function filesize(byteCount: number, options: FileSizeOptionsObject): FileSizeReturnObject
export function filesize(byteCount: number): string

export function partial(options: FileSizeOptionsString): (byteCount: number) => string
export function partial(options: FileSizeOptionsArray): (byteCount: number) => FileSizeReturnArray
export function partial(options: FileSizeOptionsExponent): (byteCount: number) => number
export function partial(options: FileSizeOptionsObject): (byteCount: number) => FileSizeReturnObject
export function partial(): (byteCount: number) => string
export function filesize(arg: any, { bits, pad, base, round, locale, localeOptions, separator, spacer, symbols, standard, output, fullform, fullforms, exponent, roundingMethod, precision }?: FileSizeOptions): string | number | any[] | {
value: any;
symbol: any;
exponent: number;
unit: string;
};

export function partial({ bits, pad, base, round, locale, localeOptions, separator, spacer, symbols, standard, output, fullform, fullforms, exponent, roundingMethod, precision }?: FileSizeOptions): (arg: any) => string | number | any[] | {
value: any;
symbol: any;
exponent: number;
unit: string;
};

0 comments on commit 3aee3e8

Please sign in to comment.