Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

NumberFormat.formatToParts() #149

Merged
merged 12 commits into from
Feb 29, 2016

Conversation

stasm
Copy link
Contributor

@stasm stasm commented Feb 26, 2016

WIP for tc39/ecma402#79. It's missing comments which I'll add once the ECMA 402 PR is reviewed.

stasm added 10 commits January 27, 2016 12:54
> require('./index').NumberFormat('en-IN', {useGrouping: false}).formatToParts(123456.01)
[ { type: 'value', name: 'integer', value: '123456' },
  { type: 'token', name: 'decimalSeparator', value: '.' },
  { type: 'value', name: 'fraction', value: '01' } ]
> require('./index').NumberFormat('pl', {useGrouping: false}).formatToParts(-123456.01)
[ { type: 'token', name: '???', value: '-' },
  { type: 'value', name: 'integer', value: '123456' },
  { type: 'token', name: 'decimalSeparator', value: ',' },
  { type: 'value', name: 'fraction', value: '01' } ]
> require('./index').NumberFormat('pl', {useGrouping: false, style: 'percent'}).formatToParts(-123456.123)
[ { type: 'token', name: '???', value: '-' },
  { type: 'value', name: 'integer', value: '12345612' },
  { type: 'token', name: '???', value: '%' } ]
> require('./index').NumberFormat('en-IN').formatToParts(-123456.123)
[ { type: 'token', name: '???', value: '-' },
  { type: 'value', name: 'group', value: '1' },
  { type: 'token', name: 'groupSeparator', value: ',' },
  { type: 'value', name: 'group', value: '23' },
  { type: 'token', name: 'groupSeparator', value: ',' },
  { type: 'value', name: 'group', value: '456' },
  { type: 'token', name: 'decimalSeparator', value: '.' },
  { type: 'value', name: 'fraction', value: '123' } ]
> require('./index').NumberFormat('pl').formatToParts(-123456.123)
[ { type: 'token', name: '???', value: '-' },
  { type: 'value', name: 'group', value: '123' },
  { type: 'token', name: 'groupSeparator', value: ' ' },
  { type: 'value', name: 'group', value: '456' },
  { type: 'token', name: 'decimalSeparator', value: ',' },
  { type: 'value', name: 'fraction', value: '123' } ]
@stasm stasm changed the title Number format.format to parts NumberFormat.formatToParts() Feb 26, 2016
@caridy
Copy link
Collaborator

caridy commented Feb 27, 2016

actually, you know what, can you revert the update the CLDR data, the last commit, so we can see the actual code changes without the interference of the cldr data?

@stasm
Copy link
Contributor Author

stasm commented Feb 27, 2016

Sure, let me do it right now.

@caridy caridy merged commit 7c59f0c into andyearnshaw:master Feb 29, 2016
caridy added a commit that referenced this pull request Feb 29, 2016
@caridy
Copy link
Collaborator

caridy commented Feb 29, 2016

I have merged this as part of the big refactor of the code, there are still issues with the sign replacements. e.g.:

$ node
> require('./')
{}
> new IntlPolyfill.NumberFormat('en', {style:'percent'}).format(1234);
'123,400{percentSign}'
>

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

Successfully merging this pull request may close these issues.

2 participants