-
-
Notifications
You must be signed in to change notification settings - Fork 97
Tweaking types and removing any usage #172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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): 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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very important to not change the behaviour of.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are correct. This was also not changed, but rather I overlooked the case that if other options are given and NOT
output
it also should return string and not force the setting ofoutput
. I will wait on the issue opener to create a PR, otherwise I can if wanted.