News for hackers. Stuff that matters.
Re:The Intl.RelativeTimeFormat API by ape4 on Monday October 22, 2018 @12:21PM (#18275981)
I'd rather see a constant symbol like

    rtf.format(3.14, Intl.RelativeTimeFormat.SECOND);
Re:The Intl.RelativeTimeFormat API by zbraniecki on Monday October 22, 2018 @02:51PM (#18277222)
Hi, 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!

Re:The Intl.RelativeTimeFormat API by wvenable on Monday October 22, 2018 @12:58PM (#18276284)
I agree. This doesn't seem to be a very clean API. It's extremely "stringy".
Re:The Intl.RelativeTimeFormat API by guachesuedehack on Monday October 22, 2018 @01:10PM (#18276385)
I agree.
Re:The Intl.RelativeTimeFormat API by evmar on Monday October 22, 2018 @03:22PM (#18277507)
You 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%2...

Re:The Intl.RelativeTimeFormat API by Waterluvian on Monday October 22, 2018 @02:15PM (#18276927)
Why not have string "constants" in the library so both methods work?
Re:The Intl.RelativeTimeFormat API by maxxxxx on Monday October 22, 2018 @03:01PM (#18277303)
Agreed. Better to have constants. That way you can quickly know what the available values are.
Re:The Intl.RelativeTimeFormat API by mathias on Tuesday October 23, 2018 @09:53AM (#18283350)
That’s not very JavaScript-y. Where else in ECMAScript are constants used like this?
Re:The Intl.RelativeTimeFormat API by Faaak on Monday October 22, 2018 @12:57PM (#18276273)
Me too. It seems way "cleaner" that way, not mixing semantics
Re:The Intl.RelativeTimeFormat API by snek on Monday October 22, 2018 @01:13PM (#18276413)
How come?
Re:The Intl.RelativeTimeFormat API by moreira on Monday October 22, 2018 @01:29PM (#18276552)
Quick - 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.

Re:The Intl.RelativeTimeFormat API by felixfbecker on Monday October 22, 2018 @01:41PM (#18276651)
TypeScript can check and autocomplete valid values of strings too, but I agree with the other points.