biegunka/terminal-size

Swap the order of the fields width/height

Opened this issue · 3 comments

In almost all API's the fields width/height are in that order, with width first. Some examples:

It's very surprising to see the fields the other way round.

BTW, I realise this would break the API, and potentially break existing clients without realising it. One solution to make the breakage more explicit would be to rename Window to Size at the same time, since the data type arguably is representing Size not Window. The other alternative of course is to not make this change at all, which I can certainly see the attraction of. As it stands, I would never rely on the order of the fields if they go height/width (since it's going to trip me up if I look back later), so am currently sticking to the selectors.

The current order mimics original POSIX API. I don't have much of an opinion on this but it doesn't look unreasonable not to export the constructor at all, so the users are forced to use height and width explicitly.

Hmm, that's the only API I've ever seen that way round, but I can see it's reasonable to follow it. Not exporting the constructor might be wise, or maybe just a comment saying why the fields are that way round, and calling out that it's different to what you might expect. Even if you don't export the constructor, the Foldable instance still leaks the order of the fields.