code: function (fn, context) {
      return function (/* arguments */) {
        var self = context || this;
        var newArgs = _.toArray(arguments);
        var callback;
  
        for (var i = newArgs.length - 1; i >= 0; --i) {
          var arg = newArgs[i];
          var type = typeof arg;
          if (type !== "undefined") {
            if (type === "function") {
              callback = arg;
            }
            break;
          }
        }
  
        if (! callback) {
          if (Meteor.isClient) {
            callback = logErr;
          } else {
            var fut = new Future();
            callback = fut.resolver();
          }
          ++i; // Insert the callback just after arg.
        }
  
        newArgs[i] = Meteor.bindEnvironment(callback);
        var result = fn.apply(self, newArgs);
        return fut ? fut.wait() : result;
      };
    }
docs: wrapAsync can wrap any function that takes some number of arguments that can't be undefined, followed by some optional arguments, where the callback is the last optional argument. e.g. fs.readFile(pathname, [callback]), fs.open(pathname, flags, [mode], [callback]) For maximum effectiveness and least confusion, wrapAsync should be used on functions where the callback is the only argument of type Function. 
  @memberOf Meteor
  @summary Wrap a function that takes a callback function as its final parameter. The signature of the callback of the wrapped function should be `function(error, result){}`. On the server, the wrapped function can be used either synchronously (without passing a callback) or asynchronously (when a callback is passed). On the client, a callback is always required; errors will be logged if there is no callback. If a callback is provided, the environment captured when the original function was called will be restored in the callback.
  @locus Anywhere
  @param {Function} func A function that takes a callback as its final parameter
  @param {Object} [context] Optional `this` object against which the original function will be invoked