You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
define(function () {
|
|
|
|
|
|
|
|
|
|
// Internal function that returns an efficient (for current engines) version
|
|
|
|
|
// of the passed-in callback, to be repeatedly applied in other Underscore
|
|
|
|
|
// functions.
|
|
|
|
|
function optimizeCb(func, context, argCount) {
|
|
|
|
|
if (context === void 0) return func;
|
|
|
|
|
switch (argCount == null ? 3 : argCount) {
|
|
|
|
|
case 1: return function(value) {
|
|
|
|
|
return func.call(context, value);
|
|
|
|
|
};
|
|
|
|
|
// The 2-argument case is omitted because we’re not using it.
|
|
|
|
|
case 3: return function(value, index, collection) {
|
|
|
|
|
return func.call(context, value, index, collection);
|
|
|
|
|
};
|
|
|
|
|
case 4: return function(accumulator, value, index, collection) {
|
|
|
|
|
return func.call(context, accumulator, value, index, collection);
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
return function() {
|
|
|
|
|
return func.apply(context, arguments);
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return optimizeCb;
|
|
|
|
|
|
|
|
|
|
});
|