i18n API - {style: "currency"} redundant when currency is declared

Norbert Lindenberg ecmascript at norbertlindenberg.com
Tue Sep 4 11:47:55 PDT 2012

If we want to go this route, I'd still keep style as the primary attribute, and let currency only set the style if it isn't already set. So:

Old: {currency: "EUR"} => {style: "decimal"}
New: {currency: "EUR"} => {style: "currency", currency: "EUR"}
- {} => {style: "decimal}
- {style: "decimal", currency: "EUR"} => {style: "decimal"}
- {style: "percent", currency: "EUR"} => {style: "percent"}
- {style: "currency", currency: "EUR"} => {style: "currency", currency: "EUR"}

It saves some typing, but makes the API a bit harder to explain. Comments?


On Sep 4, 2012, at 10:21 , Nebojša Ćirić wrote:

> Or we could throw TypeError in that case (style not matching).
> 2012/9/4 Nebojša Ćirić <cira at google.com>
> And {currency: 'USD', style:'percent'} would still produce {currency:'USD', style: 'currency'}, i.e. currency property dictates the style?
> 2012/9/4 Marcos Caceres <ecmascript at marcosc.com>
> Hi,
> If I define a "currency" option for NumberFormat, then {style: "currency"} should automagically be set, no?
> I think is redundant to have to do the following:
>  {style: "currency", currency: "USD"}.
> I should just be able to say: {currency: "USD"} without having to declare the "style".
> --
> Marcos Caceres
> http://datadriven.com.au

More information about the es-discuss mailing list