Skip to content

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.

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.

2 participants