import Ember from 'ember';

const {
  RSVP: { all },
  Helper: { helper },
  isArray,
  tryInvoke
} = Ember;

export function invoke([methodName, ...args]) {
  let obj = args.pop();
  if (isArray(obj)) {
    return function() {
      return all(
        obj.map((item) => tryInvoke(item, methodName, args))
      );
    };
  } else {
    return function() {
      return tryInvoke(obj, methodName, args);
    };
  }
}

export default helper(invoke);

@@ -1,20 +1,31 @@
 import 
+%7B is
 Ember
+Array %7D
  from 'e
@@ -32,71 +32,70 @@
 mber
-';%0A%0Aconst %7B%0A  RSVP: %7B all %7D,%0A  Helper: %7B helper %7D,%0A  isArray,%0A 
+-array/utils';%0Aimport %7B helper %7D from 'ember-helper';%0Aimport %7B
  try
@@ -104,18 +104,77 @@
 voke
-%0A%7D = Ember
+ %7D from 'ember-utils';%0Aimport RSVP from 'rsvp';%0A%0Aconst %7B all %7D = RSVP
 ;%0A%0Ae
@@ -248,16 +248,17 @@
 ();%0A
+%0A
   if (is
 Arra
@@ -253,16 +253,21 @@
   if (is
+Ember
 Array(ob
@@ -306,27 +306,22 @@
     
-return all(%0A       
+let promises =
  obj
@@ -369,23 +369,44 @@
 , args))
+;%0A
 %0A      
+return all(promises
 );%0A    %7D
@@ -414,18 +414,10 @@
 %0A  %7D
- else %7B%0A  
+%0A%0A
   re
@@ -430,26 +430,24 @@
 unction() %7B%0A
-  
     return t
@@ -481,24 +481,18 @@
 rgs);%0A  
-  %7D;%0A  
 %7D
+;
 %0A%7D%0A%0Aexpo

Clean up imports in `invoke` helper