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