source: frontend/node_modules/underscore/amd/invoke.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 852 bytes
Line 
1define(['./restArguments', './isFunction', './map', './_deepGet', './_toPath'], function (restArguments, isFunction, map, _deepGet, _toPath) {
2
3 // Invoke a method (with arguments) on every item in a collection.
4 var invoke = restArguments(function(obj, path, args) {
5 var contextPath, func;
6 if (isFunction(path)) {
7 func = path;
8 } else {
9 path = _toPath(path);
10 contextPath = path.slice(0, -1);
11 path = path[path.length - 1];
12 }
13 return map(obj, function(context) {
14 var method = func;
15 if (!method) {
16 if (contextPath && contextPath.length) {
17 context = _deepGet(context, contextPath);
18 }
19 if (context == null) return void 0;
20 method = context[path];
21 }
22 return method == null ? method : method.apply(context, args);
23 });
24 });
25
26 return invoke;
27
28});
Note: See TracBrowser for help on using the repository browser.