Add a way to do shallow equal
See original GitHub issuePossible names for a shallow eq validator:
toShallowEqual
toBe
(jest style)
Personally I like toShallowEqual
- it also goes well with toLooseEqual
that we already have.
Issue Analytics
- State:
- Created 3 years ago
- Comments:15 (11 by maintainers)
Top Results From Across the Web
Add a way to do shallow equal · Issue #87 · dethcrypto/earl
Another alternative is toStrictlyEqual which is clearer than toShallowEqual but I still prefer toBe as I'm testing for identity, not some kind ...
Read more >shallow-equal - npm
Minimalistic shallow equality check for arrays/objects. ... Start using shallow-equal in your project by running `npm i shallow-equal`.
Read more >How can I do a shallow comparison of the properties of two ...
Returns true when the values of all keys are strictly equal. ... To do a "shallow" comparison where inherited properties should be ignored ......
Read more >Shallow Compare - React
shallowCompare performs a shallow equality check on the current props and nextProps objects as well as the current state and nextState objects. It...
Read more >wordpress/is-shallow-equal | Block Editor Handbook
A function for performing a shallow comparison between two objects or arrays. Two values have shallow equality when all of their members are...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
As per discussion with @sz-piotr I decided to rename it to
toStrictlyEqual
.IMO
toBe
is too short it looks like it’s incentivizing by us to use but in reality, 95% of cases should be covered bytoEqual
. I will fix it and merge it later today.@sz-piotr So what you’re saying is that we shouldn’t allow (at least on a type system lvl) comparing primitive values with
toBe
, right?It’s an interesting point… and I think you’re right. But! We can make a signature to be more like:
toBe(value: T)
and add condition thatT extends object
. This way we get type safety.