Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(iterator-utilities): add more methods #809

Merged
merged 1 commit into from
Oct 19, 2024

Conversation

kyranet
Copy link
Member

@kyranet kyranet commented Oct 1, 2024

Added the following functions:

  • all (alias for every)
  • any (alias for some)
  • collect (alias for toArray)
  • collectInto
  • compare
  • compareBy
  • equal
  • equalBy
  • fuse
  • greaterOrEqualThan (with alias for ge)
  • greaterThan (with alias for gt)
  • inspect
  • intersperse
  • isSorted
  • isSortedBy
  • isSortedByKey
  • lessOrEqualThan (with alias for le)
  • lessThan (with alias for lt)
  • maxBy
  • maxByKey
  • minBy
  • minByKey
  • notEqual
  • nth (alias for at)
  • stepBy
  • 🔥 BREAKING CHANGE: min now uses a lexicographical comparison by default. Use minBy for custom comparisons.
  • 🔥 BREAKING CHANGE: max now uses a lexicographical comparison by default. Use maxBy for custom comparisons.

- `all` (alias for `every`)
- `any` (alias for `some`)
- `collect` (alias for `toArray`)
- `collectInto`
- `compare`
- `compareBy`
- `equal`
- `equalBy`
- `fuse`
- `greaterOrEqualThan` (with alias for `ge`)
- `greaterThan` (with alias for `gt`)
- `inspect`
- `intersperse`
- `isSorted`
- `isSortedBy`
- `isSortedByKey`
- `lessOrEqualThan` (with alias for `le`)
- `lessThan` (with alias for `lt`)
- `maxBy`
- `maxByKey`
- `minBy`
- `minByKey`
- `notEqual`
- `nth` (alias for `at`)
- `stepBy`

BREAKING CHANGE: `min` now uses a lexicographical comparison by default. Use `minBy` for custom comparisons.
BREAKING CHANGE: `max` now uses a lexicographical comparison by default. Use `maxBy` for custom comparisons.
Copy link

sonarqubecloud bot commented Oct 1, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
3.9% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud


for (const value0 of toIterableIterator(iterable)) {
const result1 = iterator1.next();
if (result1.done || !callbackFn(value0, result1.value)) return false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we get a fastpath for arrays?

Copy link
Member Author

@kyranet kyranet Oct 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quite a lot of things could get a fastpath for arrays, but that'll require adding more code to handle those cases.

That being said, I considered the possibility of having a sizeHint in our iterator, but that's a future thing.

@favna favna changed the title feat: add more methods feat(iterator-utilities): add more methods Oct 19, 2024
@favna favna merged commit 65ad816 into main Oct 19, 2024
9 of 10 checks passed
@favna favna deleted the refactor/iterator-utilities/more-methods branch October 19, 2024 11:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants