common icon indicating copy to clipboard operation
common copied to clipboard

Implement Iterator#keepLast() to allow storing last iterator value

Open lundibundi opened this issue 4 years ago • 2 comments

  • [x] code is properly formatted (npm run fmt)
  • [x] tests are added/updated
  • [x] documentation is updated (npm run doc to regenerate documentation based on comments)
  • [x] description of changes is added under the Unreleased header in CHANGELOG.md

lundibundi avatar Jul 02 '20 09:07 lundibundi

I think the proposed splitOn is something like https://github.com/metarhia/common/pull/339.

Will think about a better solution.

Leading to a situation where you have multiple iterators sharing a common state.

Though, what's wrong with this? I think it's already possible if someone wants to take values from the same iterator in multiple places (which is fine IMO) or misuses iterator (like using async function in .map etc).

lundibundi avatar Jul 06 '20 07:07 lundibundi

Though, what's wrong with this? I think it's already possible if someone wants to take values from the same iterator in multiple places (which is fine IMO) or misuses iterator (like using async function in .map etc).

The problem is that it forces programmers to save iterator pre-transformation. I know that it is currently possible to misuse iterators, but I believe that we should not encourage such patterns.

nechaido avatar Jul 06 '20 11:07 nechaido