MCPcopy Index your code
hub / github.com/jashkenas/underscore / optimizeCb

Function optimizeCb

underscore.js:745–762  ·  view source on GitHub ↗
(func, context, argCount)

Source from the content-addressed store, hash-verified

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`,

Callers 5

baseIterateeFunction · 0.70
timesFunction · 0.70
eachFunction · 0.70
createReduceFunction · 0.70
underscore.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…