Code coverage report for src/util/bindCallback.ts

Statements: 100% (15 / 15)      Branches: 100% (6 / 6)      Functions: 100% (6 / 6)      Lines: 100% (13 / 13)      Ignored: none     

All files » src/util/ » bindCallback.ts
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 261 189 18   2 2     2 2     10 32     2 2       2 2      
export function bindCallback (func: Function, thisArg, argCount): Function {
  if (typeof thisArg === 'undefined') { return func; }
  switch (argCount) {
    case 0:
      return function() {
        return func.call(thisArg);
      };
    case 1:
      return function(arg) {
        return func.call(thisArg, arg);
      };
    case 2:
      return function(value, index) {
        return func.call(thisArg, value, index);
      };
    case 3:
      return function(value, index, collection) {
        return func.call(thisArg, value, index, collection);
      };
  }
 
  return function() {
    return func.apply(thisArg, arguments);
  };
};