(func, context, argCount)
| 743 | // of the passed-in callback, to be repeatedly applied in other Underscore |
| 744 | // functions. |
| 745 | function optimizeCb(func, context, argCount) { |
| 746 | if (context === void 0) return func; |
| 747 | switch (argCount == null ? 3 : argCount) { |
| 748 | case 1: return function(value) { |
| 749 | return func.call(context, value); |
| 750 | }; |
| 751 | // The 2-argument case is omitted because we’re not using it. |
| 752 | case 3: return function(value, index, collection) { |
| 753 | return func.call(context, value, index, collection); |
| 754 | }; |
| 755 | case 4: return function(accumulator, value, index, collection) { |
| 756 | return func.call(context, accumulator, value, index, collection); |
| 757 | }; |
| 758 | } |
| 759 | return function() { |
| 760 | return func.apply(context, arguments); |
| 761 | }; |
| 762 | } |
| 763 | |
| 764 | // An internal function to generate callbacks that can be applied to each |
| 765 | // element in a collection, returning the desired result — either `_.identity`, |
no outgoing calls
no test coverage detected
searching dependent graphs…