Closed vitaly-t closed 1 year ago
I've tried to compare the logic to RXJS (where it uses a predicate):
skipWhile
is inclusivetakeWhile
is exclusiveSo that doesn't help much, though if we follow their logic in the Recipes, then it is consistent with how we do it:
skipWhile(predicate) => start(!predicate)
=> inclusivetakeWhile(predicate) => stop(!predicate)
=> exclusiveThe problem that I'm seeing now is linguistic. It makes perfect sense why skipWhile
logic produces inclusive result, and why takeWhile
produces exclusive result. But with the start
and stop
operators it is absolutely not clear, and you can assume it either way.
This brings the idea of adding skipWhile
+ takeWhile
, and retiring start
and stop
operators.
skipWhile
added, and operator start
marked deprecated
takeWhile
added, and operator stop
marked deprecated
v2.4.0 now has the new operators.
The old operators will be removed in v3.0.0, as it will be a breaking change.
TODO: Need to revisit the inclusive/exclusive logic added by skipUntil
and takeUntil
, to see if they are needed.
UPDATE
Here's what I found, after many tests and analysis...
takeWhile
must always be exclusive, based on linguistic logic (done)skipWhile
must always be inclusive, based on linguistic logic (done)The until
logic is supposed to complete the scope by reversing that:
takeUntil
must be inclusiveskipUntil
must be exclusiveThen we would have a complete logical range. ☝️
CONCLUSION
We do need to add inclusive takeUntil
and exclusive skipUntil
, to complete our logical range. 🔖
I did not feel sure about this, so I have posted a question.
Looks like my assumption was correct after all, and until
must be treated as check after
, which makes takeUntil
inclusive, and skipUntil
exclusive.
New operator takeUntil
merged into the master.
New operator skipUntil
merged into the master.
v2.5.0-beta.0 released with all 4 new operators.
v2.5.0 release completed this task.
We may have a bit of issue (or not) with the inconsistency: start logic is inclusive, while stop is exclusive, i.e. we start from the element that passes the predicate, but we stop with the element that's prior to the predicate that passed.
Should they not be both inclusive or exclusive?
@RebeccaStevens What do you think?