Skip to content

Commit

Permalink
use tryInvoke in ArrayMixin.invoke
Browse files Browse the repository at this point in the history
  • Loading branch information
bekzod committed Jun 5, 2018
1 parent 8ad2772 commit bee179d
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions packages/ember-runtime/lib/mixins/array.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import { ARRAY_AT_EACH } from '@ember/deprecated-features';
import { DEBUG } from '@glimmer/env';
import { PROXY_CONTENT } from 'ember-metal';
import { symbol, toString, HAS_NATIVE_PROXY } from 'ember-utils';
import { symbol, toString, HAS_NATIVE_PROXY, tryInvoke } from 'ember-utils';
import {
get,
set,
Expand Down Expand Up @@ -782,7 +782,7 @@ const ArrayMixin = Mixin.create(Enumerable, {
@public
*/
findBy() {
return this.find(iter(...arguments));
return find(this, iter(...arguments));
},

/**
Expand Down Expand Up @@ -841,7 +841,7 @@ const ArrayMixin = Mixin.create(Enumerable, {
@public
*/
isEvery() {
return this.every(iter(...arguments));
return every(this, iter(...arguments));
},

/**
Expand Down Expand Up @@ -899,7 +899,7 @@ const ArrayMixin = Mixin.create(Enumerable, {
@public
*/
isAny() {
return this.any(iter(...arguments));
return any(this, iter(...arguments));
},

/**
Expand Down Expand Up @@ -960,17 +960,7 @@ const ArrayMixin = Mixin.create(Enumerable, {
@public
*/
invoke(methodName, ...args) {
let ret = A();

this.forEach((x, idx) => {
let method = x && x[methodName];

if ('function' === typeof method) {
ret[idx] = args.length ? method.apply(x, args) : x[methodName]();
}
}, this);

return ret;
return this.map((item) => tryInvoke(item, methodName, args));
},

/**
Expand Down

0 comments on commit bee179d

Please sign in to comment.