compose is a rarely used function, and as of March 03 of 2024, it does not appear to be used at all. It shares one common issue with flow: it is impossible to type. There is no guarantee about the return types of the functions passed in, and it is therefore impossible to type. Additionally, it takes its functions first before its input, so the functions have an unknown return type which can't be properly resolved. If a restriction is to be enforced such that the return types of all functions is equivalent, then that would make it somewhat possible to type, but that would limits its use and the effort is better spent rewriting code to remove its use. The same arguments apply to flow, but flow has more issues which is elaborated on in the next section.
flow is commonly used around complex combinations of filter, uniq, map, and so on. The function made sense in the past, at a time when JavaScript did not have the suitable built-in functions for operating on Arrays. However, that time is then and ES5 has become a common standard: it is even supported by IE10 and IE11.
ES5 has introduced built-in functions such as filter and map which can be chained, unlike the old functions:
Code: Select all
// ES5
[].map(k => k + 3).filter(k => k > 10)
// collections.ts@tgui/common
filter(k => k > 10)(map(k => k + 3)([]))
// collections.ts + fp.js @ tgui/common
flow([map(k => k + 3), filter(k => k > 10)])([])
In other words, I am on a mission to fully move tgui to TypeScript and I believe that removing these files is a step towards that mission.
Note: I am willing to work on this project if the idea is approved.