Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove any usage and allow passing options without output property
- Loading branch information
1 parent
dea30ba
commit c42acc0
Showing
1 changed file
with
55 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,63 @@ | ||
export interface FileSizeOptions { | ||
interface FileSizeOptionsBase { | ||
base?: number; | ||
bits?: boolean; | ||
exponent?: number; | ||
fullform?: boolean; | ||
fullforms?: string[]; | ||
locale?: string | boolean; | ||
localeOptions?: Intl.DateTimeFormatOptions; | ||
pad?: boolean; | ||
base?: number; | ||
precision?: number; | ||
round?: number; | ||
locale?: string; | ||
localeOptions?: {}; | ||
roundingMethod?: 'round' | 'floor' | 'ceil'; | ||
separator?: string; | ||
spacer?: string; | ||
symbols?: {}; | ||
standard?: 'iec' | 'jedec'; | ||
output?: 'array' | 'exponent' | 'object' | 'string'; | ||
fullform?: boolean; | ||
fullforms?: any[]; | ||
exponent?: number; | ||
roundingMethod?: 'round' | 'floor' | 'ceil'; | ||
precision?: number; | ||
symbols?: { | ||
iec: { | ||
bits: string[], | ||
bytes: string[] | ||
}, | ||
jedec: { | ||
bits: string[], | ||
bytes: string[] | ||
} | ||
}; | ||
} | ||
|
||
interface FileSizeOptionsArray extends FileSizeOptionsBase { | ||
output: 'array' | ||
} | ||
|
||
interface FileSizeOptionsExponent extends FileSizeOptionsBase { | ||
output: 'exponent' | ||
} | ||
|
||
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; | ||
}; | ||
interface FileSizeOptionsObject extends FileSizeOptionsBase { | ||
output: 'object' | ||
} | ||
|
||
interface FileSizeOptionsString extends FileSizeOptionsBase { | ||
output: 'string' | ||
} | ||
|
||
interface FileSizeReturnObject { | ||
value: string, | ||
symbol: string, | ||
exponent: number, | ||
unit: string, | ||
} | ||
|
||
type FileSizeReturnArray = [ number, string ] | ||
|
||
export function filesize(byteCount: number, options: FileSizeOptionsString | FileSizeOptionsBase): 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 | FileSizeOptionsBase): (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 |