-
Notifications
You must be signed in to change notification settings - Fork 1
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: Rework intersect
, add overlap
#8
Conversation
…allow custom compare function BREAKING CHANGE: `distinct` no longer uses deep equal compare. Use `distinctBy` with custom compare function to parse object arrays. ```js // old distinct([1, {a: 2}, {a: 2}]) // => [1, {a: 2}] // new import deepEquals from "fast-deep-equal" distinctBy(deepEquals, [1, { a: 2 }, { a: 2 }]) // => [1, {a: 2}] ```
…o a set (array of unique items)
Hey @dgilperez, added this PR based on your #7 proposal. Waiting for your thought and can continue with |
Hey, sorry for the delay @andreidmt The changes on Otoh, I think |
BREAKING CHANGE: Functions renamed: - "join" -> "unit" - "overlap" -> "join"
I like the idea of syncing the naming with SQL operations (where applicable). Renamed "overlap" -> "join" and the old join to "unite". |
# [6.0.0](v5.4.0...v6.0.0) (2021-04-27) ### Features * Rework `intersect`, add `overlap` ([#8](#8)) ([f80680b](f80680b)) ### BREAKING CHANGES * `distinct` no longer uses deep equal compare. Use `distinctBy` with custom compare function to parse object arrays. ```js // old distinct([1, {a: 2}, {a: 2}]) // => [1, {a: 2}] // new import deepEquals from "fast-deep-equal" distinctBy(deepEquals, [1, { a: 2 }, { a: 2 }]) // => [1, {a: 2}] ``` * feat: Add `overlap` and `overlapBy` functions to combine 2 arrays into a set (array of unique items) * feat: Add `intersect` and `intersectBy` functions to obtain common items in 2 arrays * feat: rename "join" -> "unit", "overlap" -> "join" * Functions renamed: - "join" -> "unit" - "overlap" -> "join" * chore: fix linting errors
🎉 This PR is included in version 6.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Thoughts and proposals on #7 by @dgilperez:
intersect
is misleading. Implemented it as you proposed and as any sane person would expectintersect
to behave, return common items.deepEquals
so I've createdintersectBy
to be geared towards object arrays and leftintersect
with a shallow equals.intersect
asoverlap
/overlapBy
. As I'm writing,union
seems a better name for it.intersect
andoverlap
is the return of distinct items.Primary
intersect
to return common and distinct items from two arrays.intersectBy
. Allow custompredicate
andmerge
functions, geared towards object arrays.overlap
andoverlapBy
functions to combine two arrays into one with distinct items.Secondary
distinct
to use shallow compare.distinctBy
. Allow custom compare function, geared towards object arrays.Checklist
src/index.js