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