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

Function optimizeCb

underscore-node-f.cjs:738–755  ·  view source on GitHub ↗
(func, context, argCount)

Source from the content-addressed store, hash-verified

736// of the passed-in callback, to be repeatedly applied in other Underscore
737// functions.
738function 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`,

Callers 5

baseIterateeFunction · 0.70
timesFunction · 0.70
eachFunction · 0.70
createReduceFunction · 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…