material-motion-js
material-motion-js copied to clipboard
Positional sugar for operators that usually take one arg
The named arguments pattern is great for functions that take multiple arguments. We moved all operators to it in #193. However, there are some operators that usually take a single argument; they have been made harder to read and to use by the transition.
Therefore, I'm going to go back and add positional sugar for operators with one primary argument:
added/subtracted/multiplied/dividedBydistanceFromlogpluckisAnyOfrewriteTothresholdstartWithmergeappendUnit_map_tap_filter_slidingWindow
For consistency, they will keep their named argument signatures as the primary entry. The positional alternative is just sugar, because this:
translate$.distanceFrom({ x: 100, y: 100 }).threshold(70).isAnyOf([ ThresholdRegion.ABOVE ]).rewriteTo(100);
is easier to read and to write than:
translate$.distanceFrom({ origin: { x: 100, y: 100 } }).threshold({ limit: 70 }).isAnyOf({ matches: [ ThresholdRegion.ABOVE ] }).rewriteTo({ value: 100 });