-
Notifications
You must be signed in to change notification settings - Fork 127
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
[Feature Request]: Object property predicates like hasProp
(includes proof of concept)
#461
Comments
I was playing around with this idea a bit more and I think three helpers would be enough to cover any case I could think of.
I implemented a proof of concept for this in this typescript playground. |
hasProp
(includes proof of concept)
Hey, sorry for the long delay in getting back to you. I'm supportive of all of these if you want to send a PR to add them.
|
hmm whats the reasoning here? Isn't shallowEquals and deepEquals an established naming pattern? anyway, I agree with deprecating equals because it's unclear what it does and we could just make it an alias of the deep equals function |
isEqual and isDeepEqual are also fine if we want functions that return a boolean to start with is or has. But I've never seen |
I'm very pedantic, so I like the convention of isXXX for boolean functions; I like it so much that I even prefer to avoid hasXXXX when I can and consider the isXXX convention a syntactic requirement. At facebook all async functions had to be called |
@TkDodo - just realized you were referring to the plural 's' at the end of To summarize, we should have an |
No worries on response times. I totally get it! 😁 I'll see if I can get a PR up this week. |
could we explicit and do But looking at the PR, it says that:
|
Good point of clarification. I misunderstood "shallow equality" to be essentially a synonym for "referential equality". I'm primarily interested in comparing primitives so I'm down for whichever approach you both think is best. |
my suggestion would be:
also:
@eranhirsch is that alright ? |
Sounds good! |
Well... one point, about discoverability, If we put everything under a single namespace it's easier for people to find it, |
disadvantage is that those wouldn't be tree-shakable, and we don't have those "namespaces" anywhere else. The only thing this is currently used for is for |
The other alternative is |
if the issue is discoverability, I think searching for |
I often find myself wanting to
filter
an array based on whether or not a property exists or that has a property of a certain value (like when working with discriminated unions).I'm wondering if there's interest in adding some helpers like
hasNonNilProperty
orhasPropertyWithValue
to the library. I'm happy to work on a PR if this seems like something reasonable to add.I made a Typescript Playground with a couple contrived examples of the type of predicates I'm hoping to add helpers for.edit: see next comment for playgroundThe text was updated successfully, but these errors were encountered: