Skip to content
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

fixup: Add interface for filesize options object #171

Merged
merged 1 commit into from
Jul 25, 2023

Conversation

aitk
Copy link
Contributor

@aitk aitk commented Jul 21, 2023

This will provide consistency between filesize and partial function options.

This will also fix an issue I had while utilising the library where I want to validate the options supplied to a generic formatter function for example here is my implementation.

interface SomeNumberOptions = {
   compact: bool
}

const getFormatter = (type: string): (value: any, options: SomeNumberOptions | FileSizeOptions) => string {
    const formatters = {
         number: (value: number, options: SomeNumberOptions): string => {...}
         bytes: (value: number, options: FileSizeOptions): string => {...}
    }
    
    return formatters[type]
}

I've also updated some options from strings to unions.

Unverified

This user has not yet uploaded their public signing key.
Will allow casting to the options shape
@aitk aitk force-pushed the fixup/export-options-as-interface branch from 8526ad0 to 2da3aaf Compare July 21, 2023 10:20
@avoidwork avoidwork merged commit 1c3d6da into avoidwork:master Jul 25, 2023
@aitk aitk deleted the fixup/export-options-as-interface branch July 25, 2023 11:23
@avoidwork
Copy link
Owner

This is 10.0.8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants