4 ms·
I'd rather see a constant symbol like rtf.format(3.14, Intl.RelativeTimeFormat.SECOND);
by ape4 8y ago
I'd rather see a constant symbol like
rtf.format(3.14, Intl.RelativeTimeFormat.SECOND);
- Faaak 8y agoMe too. It seems way "cleaner" that way, not mixing semantics
- wvenable 8y agoI agree. This doesn't seem to be a very clean API. It's extremely "stringy".
- guachesuedehack 8y agoI agree.
- snek 8y agoHow come?
- moreira 8y agoQuick - is 'seconds' a valid value for the second parameter? You don't know; there's no easy way to know. If they're constants you can look at all constants available for Intl.RelativeTimeFormat, IDEs can do autocomplete, analysers can check if the value is valid and alert if not. That's just off the top of my head; I imagine there are even more reasons.
- felixfbecker 8y agoTypeScript can check and autocomplete valid values of strings too, but I agree with the other points.
- deleted 8y ago[deleted]
- Waterluvian 8y agoWhy not have string "constants" in the library so both methods work?
- zbraniecki 8y agoHi, I'm the author of the API proposal (together with Rafael and Daniel). Thanks for feedback! I understand where your suggestion is coming from, but please, take into account that we are designing the API to fit into the whole ECMA402 Intl API model. The API we ended up with seems to be more consistent with it than what you suggested. It also allows us to, in the future extend it to compound units more easily. Saying that, if you have a motivational o help us, come to ecma402 and review our active proposals! We have a bunch such as Intl.Locale, Number first revision, ListFormat etc :) That's a great time to work on the design of them! Hope that helps!
- maxxxxx 8y agoAgreed. Better to have constants. That way you can quickly know what the available values are.
- evmar 8y agoYou could just as well typo the ".SECOND" in the above. Plenty of existing JS APIs do the stringly thing here, so the proper thing for a checker to do is just check the strings. Try putting your cursor between the quotes here and hit ctl-space: http://www.typescriptlang.org/play/#src=fetch(%7B%0D%0A%20%20%20%20credentials%3A%20%22%22%0D%0A%7D) http://www.typescriptlang.org/play/#src=fetch(%7B%0D%0A%20%2...
- mathias 8y agoThat’s not very JavaScript-y. Where else in ECMAScript are constants used like this?