I was browsing an old code of mine when I saw this line const removeShortSentences = R.compose( R.lt(3), R.length, R.split(".") ) I was surprised by how unreadable the piece with R.lt is, as all it does is to save a few characters. The same logic without R.lt has much clearer intent: const removeShortSentences = R.compose( … Continue reading R.lt – are we that lazy?
R.partition The method is similar to R.filter, but it instead of returning single list with all list members passing the predicate function, it return two lists. First list is the same as the result of R.filter, i.e. all instances of the list passing the predicate. The second list holds all list members that doesn't pass … Continue reading R.partition – extended version of R.filter
It is a common ESLint rule to warn for nested ternaries. Even if it wasn't such rule available, it is a bad practice and it hurts code's readability. const foo = x > 3 ? 7 : x > 10 ? 5 : 6 One simple way to solve it with if/else statements or usage … Continue reading Use R.maybe instead of nested ternaries
It is fairly easy to overestimate the value of having a pattern when writing the commit messages. But if you work in a large project(as you should), you will realize that it is important to have stricter rules in this regard. Commit message libraries CommitlintCommitizenCommit-message While the first two are popular and widely used, I … Continue reading Using assisted generation of commit messages