-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
separate R.where into two simpler functions: R.where and R.whereEq #1036
Conversation
@@ -50,17 +27,13 @@ describe('where', function() { | |||
}); | |||
|
|||
it('is false if the test object is null-ish', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd love to remove this special case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⚡
1fc3c7b
to
497119f
Compare
IMO |
I'm fine with this as long as whereEq = compose(where, mapObject(eq)) |
Damn, it hadn't hit me how straightforward that conversion was:
Nice. |
Shall I add |
I could be happy with this version of |
not reservations. just not seeing the point particularly. |
I say yes, then. Two simple functions beat one complex function hands-down. |
I've added |
* spec's own properties, accessing that property of the object gives the same | ||
* value (in `R.eq` terms) as accessing that property of the spec. | ||
* | ||
* `whereEq` is a specialization of [`where`](#where). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this valid use of the word specialization?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say so.
((:bell:)) @buzzdecafe, @CrossEye |
i don't mind the complexity of the original. i don't really object to this, but it doesn't excite me either. i expect this may break a lot of stuff that uses this is nice: |
Certainly. In most cases, users will need to replace -R.where({x: 1, y: 2})
+R.whereEq({x: 1, y: 2}) In each of the remaining cases, each non-function value in the spec must be wrapped with -R.where({x: 1, y: 2, z: R.gte(R.__, 0)})
+R.where({x: R.eq(1), y: R.eq(2), z: R.gte(R.__, 0)}) |
Sorry, I thought I'd made it clear that I was in favor of this. I do think that sometime soon, we'll have to look at the basic implementation. If I'm not mistaken, in the Great Curry Debacle of 2014, we reset this one in such a way that it might have lost some of the benefits that had been gained by the initial manual currying we had done. This one was the function that showed us the need for changes to our old currying, and it had some interesting behavior... |
separate R.where into two simpler functions: R.where and R.whereEq
Let's just make sure this is bold, highlighted, underlined in change log as
|
yep, totally agree |
not sure what to make of this: http://jsperf.com/mapobj-test |
I could certainly get behind a more efficient implementation. It was API complexity this pull request sought to reduce. |
|
||
return _satisfiesSpec(spec, parsedSpec, testObj); | ||
for (var prop in spec) { | ||
if (_has(prop, spec) && !spec[prop](testObj[prop])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason you're not using keys
here (it'd be faster)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like a good idea to me!
Closes #1032
This is the alternative to #1034. If we decide we want both functions we need to decide what to name them. :)