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
findKey/findIndex is inconsistent with map/list agnosticism of most other methods #740
Comments
I guess I could just use |
I would be happy to consider a PR for including I disagree that the other indexed methods like |
Hmmm. I'm just thinking about the behavior of JS arrays and objects. For instance, given that "numeric" object keys come first in a |
I think you're right. Thanks for the discussion and sorry for the delay. Check out the commit for details. |
Oh wow, no, thank you! And I think you're right about |
One of my favorite things about immutable.js is that most methods like
map
,filter
, evenconcat
,flatten
,reduce
,join
, etc. are present for bothKeyedIterable
andIndexedIterable
, and the object/array distinctions are almost erased. Why then doesKeyedIterable
havefindKey
, andIndexedIterable
havefindIndex
? Everyone knows that a JS array index is actually just a hash key, and I find myself writing a findKey wrapper method that works on any immutableIterable
.It's fine to keep
findIndex
I suppose, butIndexedIterable
should also havefindKey
.Would you accept a PR for this?
For that matter, it seems to me that well-defined semantics for sequential index specific methods like
indexOf
,zip
, etc. could have well-defined semantics over the numeric keys ofKeyedIterable
s as well and the two could be fully merged once and for all, except perhaps with some ontologic knowledge of whethertoJS
should create an array or object. The schizophrenia of JS objects and arrays just causes awkwardness, in my opinion; I think they should either be totally interchangeable or totally uninterchangable.The text was updated successfully, but these errors were encountered: