MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / bindCallback

Function bindCallback

lib/web/jshint.js:4419–4443  ·  view source on GitHub ↗

* A specialized version of `baseCallback` which only supports `this` binding * and specifying the number of arguments to provide to `func`. * * @private * @param {Function} func The function to bind. * @param {*} thisArg The `this` binding of `func`. * @param {number} [

(func, thisArg, argCount)

Source from the content-addressed store, hash-verified

4417 * @returns {Function} Returns the callback.
4418 */
4419 function bindCallback(func, thisArg, argCount) {
4420 if (typeof func != 'function') {
4421 return identity;
4422 }
4423 if (thisArg === undefined) {
4424 return func;
4425 }
4426 switch (argCount) {
4427 case 1: return function(value) {
4428 return func.call(thisArg, value);
4429 };
4430 case 3: return function(value, index, collection) {
4431 return func.call(thisArg, value, index, collection);
4432 };
4433 case 4: return function(accumulator, value, index, collection) {
4434 return func.call(thisArg, accumulator, value, index, collection);
4435 };
4436 case 5: return function(value, other, key, object, source) {
4437 return func.call(thisArg, value, other, key, object, source);
4438 };
4439 }
4440 return function() {
4441 return func.apply(thisArg, arguments);
4442 };
4443 }
4444
4445 /**
4446 * Creates a clone of the given array buffer.

Callers 11

baseCallbackFunction · 0.85
createAssignerFunction · 0.85
createForEachFunction · 0.85
createForInFunction · 0.85
createForOwnFunction · 0.85
cloneFunction · 0.85
cloneDeepFunction · 0.85
isEqualFunction · 0.85
isMatchFunction · 0.85
runInContextFunction · 0.85
timesFunction · 0.85

Calls 2

applyMethod · 0.65
callMethod · 0.45

Tested by

no test coverage detected