code: function toFunction(args, stub) {
    var obj = args[0];
    var method = args[1];
    var fn = args[2] || function() {};
  
    switch (args.length) {
    case 0: return function noop() {};
    case 1: return function(args) { return obj.apply(null, args); };
    case 2:
    case 3:
    default:
      var m = obj[method];
      stub.method = method;
      stub.fn = m;
      stub.obj = obj;
      obj[method] = stub;
      return function(args) {
        return fn.apply(obj, args);
      };
    }
  }
docs: To function.
  
  @param {*} ...args
  @param {Function} stub
  @return {Function}
  @api private