Skip to content
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

[DOC] Update documentation for EmberArray.any #18229

Merged
merged 1 commit into from
Oct 26, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions packages/@ember/-internals/runtime/lib/mixins/array.js
Original file line number Diff line number Diff line change
Expand Up @@ -860,11 +860,10 @@ const ArrayMixin = Mixin.create(Enumerable, {
},

/**
Returns `true` if the passed function returns true for any item in the
enumeration.

The callback method you provide should have the following signature (all
parameters are optional):
The any() method executes the callback function once for each element
present in the array until it finds the one where callback returns a truthy
value (i.e. `true`). If such an element is found, any() immediately returns
true. Otherwise, any() returns false.

```javascript
function(item, index, array);
Expand All @@ -874,18 +873,21 @@ const ArrayMixin = Mixin.create(Enumerable, {
- `index` is the current index in the iteration.
- `array` is the array object itself.

It must return a truthy value (i.e. `true`) to include an item in the
results. Any non-truthy return value will discard the item from the
results.

Note that in addition to a callback, you can also pass an optional target
object that will be set as `this` on the context. This is a good way
to give your iterator function access to the current object.
object that will be set as `this` on the context. It can be a good way
to give your iterator function access to an object in cases where an ES6
arrow function would not be appropriate.

Usage Example:

```javascript
if (people.any(isManager)) {
let includesManager = people.any(this.findPersonInManagersList, this);

let includesStockHolder = people.any(person => {
return this.findPersonInStockHoldersList(person)
});

if (includesManager || includesStockHolder) {
Paychecks.addBiggerBonus();
}
```
Expand Down