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(multisets): add difference, union, intersect, isContains, symmetric difference (xor), and isEqual #368

Draft
wants to merge 27 commits into
base: master
Choose a base branch
from

Conversation

eranhirsch
Copy link
Collaborator

@eranhirsch eranhirsch commented Aug 28, 2023

Adding multi-set functions:

  • Difference
  • Union
  • Intersect
  • IsContains
  • Symmetric Difference ("XOR")
  • isEqual
  • isDisjoint (this doesn't have any multiset specific impl concerns)

Closes #363


Make sure that you:

  • Typedoc added for new methods and updated for changed
  • Tests added for new methods and updated for changed
  • New methods added to src/index.ts

@eranhirsch eranhirsch requested a review from TkDodo August 28, 2023 08:29
@codesandbox-ci
Copy link

codesandbox-ci bot commented Aug 28, 2023

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit e64e0f1:

Sandbox Source
remeda-example-vanilla Configuration

@codecov
Copy link

codecov bot commented Aug 28, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.01% 🎉

Comparison is base (0138d52) 99.88% compared to head (e64e0f1) 99.90%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #368      +/-   ##
==========================================
+ Coverage   99.88%   99.90%   +0.01%     
==========================================
  Files         112      128      +16     
  Lines        6845     8007    +1162     
  Branches      618      709      +91     
==========================================
+ Hits         6837     7999    +1162     
  Misses          8        8              
Files Changed Coverage Δ
src/_createLazyDifferenceMultiSetByEvaluator.ts 100.00% <100.00%> (ø)
src/_createLazyIntersectionMultiSetByEvaluator.ts 100.00% <100.00%> (ø)
src/_isContainsMultiSetImplementation.ts 100.00% <100.00%> (ø)
src/_isEqualMultiSetImplementation.ts 100.00% <100.00%> (ø)
src/_reduceLazy.ts 100.00% <100.00%> (ø)
src/difference.ts 100.00% <100.00%> (ø)
src/differenceMultiSet.ts 100.00% <100.00%> (ø)
src/differenceMultiSetBy.ts 100.00% <100.00%> (ø)
src/differenceWith.ts 100.00% <100.00%> (ø)
src/filter.ts 100.00% <100.00%> (ø)
... and 16 more

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@eranhirsch eranhirsch changed the title feat(multiset): Add differenceMultiset function feat(multiset): Add multiset functions Aug 28, 2023
@eranhirsch eranhirsch changed the title feat(multiset): Add multiset functions feat: Add multiset functions Aug 28, 2023
@eranhirsch eranhirsch changed the title feat: Add multiset functions feat(multisets): add difference, union, intersect, isContains, symmetric difference (xor), and isEqual Aug 29, 2023
@eranhirsch eranhirsch marked this pull request as draft September 6, 2023 08:19
@eranhirsch
Copy link
Collaborator Author

I have some ideas about how to get this API right, I want to drop the multiset names and just rename the regular functions, i'll send out smaller PRs in the near future

@mwarger
Copy link

mwarger commented Nov 8, 2023

@eranhirsch Just curious about this one - any luck?

@eranhirsch
Copy link
Collaborator Author

It's a busy period for me and I didn't get around to doing this. You can see it's a pretty big change if we want to cover all the cases, i want to split this into smaller parts but I just didn't find the time yet.

@eranhirsch eranhirsch mentioned this pull request Mar 11, 2024
4 tasks
eranhirsch added a commit that referenced this pull request Mar 15, 2024
A type-guard that checks existence in a set of values. Useful for
narrowing possible enum (literal union) values via a global const.

Optimizes dataFirst and dataLast implementations offering better
performance for each case.

Deprecated intersection and difference in favour of using filter in
combination with isIncludedIn so we can take advantage of the
performance gains and optimizations, and to make room for future
interestion and difference functions which will work more closely to the
mathematical definitions of multi-sets (which take into account
duplicate items, as could be present in arrays). See #368

---

Make sure that you:

- [x] Typedoc added for new methods and updated for changed
- [x] Tests added for new methods and updated for changed
- [x] New methods added to `src/index.ts`
- [ ] New methods added to `mapping.md`

---

<details><summary>We use semantic PR titles to automate the release
process!</summary>

https://conventionalcommits.org

PRs should be titled following using the format: `< TYPE >(< scope >)?:
description`

### Available Types:

- `feat`: new functions, and changes to a function's type that would
impact users.
- `fix`: changes to the runtime behavior of an existing function, or
refinements to it's type that shouldn't impact most users.
- `perf`: changes to function implementations that improve a functions
_runtime_ performance.
- `refactor`: changes to function implementations that are neither `fix`
nor `perf`
- `test`: tests-only changes (transparent to users of the function).
- `docs`: changes to the documentation of a function **or the
documentation site**.
- `build`, `ci`, `style`, `chore`, and `revert`: are only relevant for
the internals of the library.

For scope put the name of the function you are working on (either new or
existing).

</details>
@eranhirsch
Copy link
Collaborator Author

difference and intersection are now part of v1 as a variant (difference.multiset and intersection.multiset), and in v2 as the only implementation.

Other functions would be added directly to v2 after release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feature request: xor
2 participants