MCPcopy Create free account
hub / github.com/PrairieLearn/PrairieLearn / optimizeCb

Function optimizeCb

public/javascripts/underscore.js:63–82  ·  view source on GitHub ↗
(func, context, argCount)

Source from the content-addressed store, hash-verified

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

Callers 3

cbFunction · 0.70
underscore.jsFile · 0.70
createReduceFunction · 0.70

Calls 1

callMethod · 0.80

Tested by

no test coverage detected