Skip to content

Replace any in favour of some to align with regular JS#233

Closed
cibernox wants to merge 2 commits intoemberjs:masterfrom
cibernox:add_enumerable_some
Closed

Replace any in favour of some to align with regular JS#233
cibernox wants to merge 2 commits intoemberjs:masterfrom
cibernox:add_enumerable_some

Conversation

@cibernox
Copy link
Contributor

@cibernox cibernox commented Jun 29, 2017

@cibernox cibernox changed the title Add RFC to deprecate any in favour of some Replace any in favour of some to align with regular JS Jun 29, 2017
@cibernox
Copy link
Contributor Author

@alexspeller You might have something to say as this is almost a copy of another RFC you made, with the exception that we don't have to polyfill this feature since it is available even in IE9.

@alexspeller
Copy link
Contributor

Definitely in favour, and also in favour of renaming isAny to isSome for consistency. I think the small amount of very easily updatable churn is worth it to keep more in line with standards.


# Detailed design

The first step is to rename `any` to `some` and recreate `any` as simply an alias
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to leave the deprecation part optional, that is why I mentioned the deprecation as a separate step. In case we decide to implemente and deprecate, deprecatingAlias is indeed how I'd implement this.

@mmun mmun added T-framework RFCs that impact the ember.js library T-deprecation labels Aug 1, 2017
@Serabe
Copy link
Member

Serabe commented Sep 25, 2017

One quick comment on this. Though documentation still says otherwise, Array.any is currently returning the first truthy value:

let arr = emberA([undefined, null, false, 5]);
let result = arr.any(o => o);

assert.equal(result, 5);

Can you change the RFC to accomodate to some returning always a boolean? I mean, the change would be something like:

{
  some(...args) {
    return !!this.any(...args);
  }
}

And there might be people out there relying on the fact that any returns it, so there needs to be a guide to tell them to use find instead.

Thank you!

@locks
Copy link
Contributor

locks commented Sep 25, 2017

To build on top of @Serabe's latest comment, I don't think this should be framed as aliasing, given that the two methods have slightly different semantics in practice.
Or in other words: #136 (comment).

@locks
Copy link
Contributor

locks commented Jan 18, 2020

With Octane shipped, we are no longer looking to make changes to this part of the framework. Thanks to all involved for your effort!

@locks locks closed this Jan 18, 2020
@NullVoxPopuli
Copy link
Contributor

This is because any only exists on ember array, yeah?
And octane doesn't have prototype extensions, so regular arrays don't have any.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Champion T-deprecation T-framework RFCs that impact the ember.js library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants