Open adamhamlin opened 1 year ago
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
radash-docs | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Jul 8, 2023 3:16pm |
@rayepps bump
Hey @adamhamlin thanks for the PR 🙏 and apologies for the delay 🙃 I think the collect
function as you've implemented it is super similar to the existing select function. Although, there is no selectFirst
.
Hey @adamhamlin thanks for the PR 🙏 and apologies for the delay 🙃 I think the
collect
function as you've implemented it is super similar to the existing select function. Although, there is noselectFirst
.
Yes, I definitely agree that collect
and select
are duplicative. Reworking this PR to add selectFirst
is certainly doable, but as I kind of alluded to in the associated issue, I think the semantics of collect
and collectFirst
are preferable--namely, using a single function arg instead of 2.
In practice when using collect
, I find myself doing something like the following that would require some code duplication using select
, for example:
const selectRes = select(
myArr,
(someObj) => someObj.nestedProp.valueIWant,
(someObj) => someObj.nestedProp.valueIWant !== undefined
);
// versus...
const collectRes = collect(
myArr,
(someObj) => someObj.nestedProp.valueIWant
);
Obviously, it's up to you. Ultimately, if we go with collect
/collectFirst
, it would probably warrant deprecating select
at some point.
This PR has conflicts now, so I'll wait to hear back from you before fixing those up.
Description
Adds two new functions:
collect
andcollectFirst
. See more info/discussion in #269.collect
- Map+filter operation where undefined transformations are filtered outcollectFirst
- Map+find operation where the first defined transformation is returnedChecklist
package.json
has been bumped (matching semver)yarn build
command has been run and to update thecdn
directory/docs
directory) has been updatedResolves
Resolves #269