(func, context, argCount)
| 61 | // of the passed-in callback, to be repeatedly applied in other Underscore |
| 62 | // functions. |
| 63 | var optimizeCb = function(func, context, argCount) { |
| 64 | if (context === void 0) return func; |
| 65 | switch (argCount == null ? 3 : argCount) { |
| 66 | case 1: return function(value) { |
| 67 | return func.call(context, value); |
| 68 | }; |
| 69 | case 2: return function(value, other) { |
| 70 | return func.call(context, value, other); |
| 71 | }; |
| 72 | case 3: return function(value, index, collection) { |
| 73 | return func.call(context, value, index, collection); |
| 74 | }; |
| 75 | case 4: return function(accumulator, value, index, collection) { |
| 76 | return func.call(context, accumulator, value, index, collection); |
| 77 | }; |
| 78 | } |
| 79 | return function() { |
| 80 | return func.apply(context, arguments); |
| 81 | }; |
| 82 | }; |
| 83 | |
| 84 | // A mostly-internal function to generate callbacks that can be applied |
| 85 | // to each element in a collection, returning the desired result — either |
no test coverage detected