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

Add support for localeOptions option: allow customization of i18n output #102

Merged
merged 3 commits into from
Sep 11, 2019
Merged

Add support for localeOptions option: allow customization of i18n output #102

merged 3 commits into from
Sep 11, 2019

Conversation

christopherscott
Copy link
Contributor

This PR adds support for passing an additional parameter localeOptions that is used when an explicit locale is passed to allow for further customization of the output. Defaults to {}.

This is particularly useful for places where filesize is highly dynamic/animated and there is a desire to enforce a number of fixed digits, even in cases where the decimal would be zero:

Example without (notice the left-shift of the digits when no zero decimal):
Sep-11-2019 12-23-00

Example with:
Sep-11-2019 12-23-18

Usage:

filesize(1024, {
  locale: "en-us",
  localeOptions: { minimumFractionDigits: 1 }
})

// => "1.0 KB"

The options are from ECMA-402, and are documented on MDN.

@avoidwork avoidwork merged commit d2ada9d into avoidwork:master Sep 11, 2019
@avoidwork
Copy link
Owner

Thanks! I'll prep a release

christopherscott added a commit to christopherscott/DefinitelyTyped that referenced this pull request Sep 11, 2019
Related to: avoidwork/filesize.js#102

Updates the `Options` type to allow for an optional `localeOptions` object to be passed in. `NumberFormatOptions` is [provided by typescript](https://github.com/Microsoft/TypeScript/blob/master/src/lib/es5.d.ts#L4060).
christopherscott added a commit to christopherscott/DefinitelyTyped that referenced this pull request Sep 11, 2019
Related to: avoidwork/filesize.js#102

Updates the `Options` type to allow for an optional `localeOptions` object to be passed in. `NumberFormatOptions` is [provided by typescript](https://github.com/Microsoft/TypeScript/blob/master/src/lib/es5.d.ts#L4060).
christopherscott added a commit to christopherscott/DefinitelyTyped that referenced this pull request Sep 11, 2019
Related to: avoidwork/filesize.js#102

Updates the `Options` type to allow for an optional `localeOptions` object to be passed in. `NumberFormatOptions` is [provided by typescript](https://github.com/Microsoft/TypeScript/blob/master/src/lib/es5.d.ts#L4060).
orta pushed a commit to DefinitelyTyped/DefinitelyTyped that referenced this pull request Sep 16, 2019
Related to: avoidwork/filesize.js#102

Updates the `Options` type to allow for an optional `localeOptions` object to be passed in. `NumberFormatOptions` is [provided by typescript](https://github.com/Microsoft/TypeScript/blob/master/src/lib/es5.d.ts#L4060).
pheromonez pushed a commit to class-clown/DefinitelyTyped that referenced this pull request Sep 17, 2019
…ped#38309)

Related to: avoidwork/filesize.js#102

Updates the `Options` type to allow for an optional `localeOptions` object to be passed in. `NumberFormatOptions` is [provided by typescript](https://github.com/Microsoft/TypeScript/blob/master/src/lib/es5.d.ts#L4060).
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