<commit_before>
var Promise = require('es6-promise').Promise;
var util = require('util');
var tools = require('./tools');
var either = require('./tools').either;
var makeDDPClientFactory = require('./ddp');

module.exports = MeteorTransponder;

function MeteorTransponder(requestGagarinConfig) {
  "use strict";

  var self = this;

  var ddpClientAsPromise = makeDDPClientFactory(requestGagarinConfig);

  function factory(name) {
    return function (code, args) {
      var cb = arguments[arguments.length-1];

      if (arguments.length < 3) {
        args = [];
      } else {
        args = Array.isArray(args) ? args : [ args ];
      }

      //-------------------------------------------------
      return ddpClientAsPromise().then(function (ddpClient) {
        ddpClient[name](code, args, cb);
      });
    }
  }

  self.promise = factory('promise');
  self.execute = factory('execute');

  self.wait = function (timeout, message, code, args) {
    var cb = arguments[arguments.length-1];

    if (arguments.length < 4) {
      args = [];
    } else {
      args = Array.isArray(args) ? args : [ args ];
    }

    //-----------------------------------------------------
    return ddpClientAsPromise().then(function (ddpClient) {
      ddpClient.wait(timeout, message, code, args, cb);
    });
  }

  self.start = function (cb) {
    return requestGagarinConfig().then(function (value) {
      cb(null, value);
    }, function (err) {
      cb(err);
    });
  };

  self.restart = function (restartTimeout, cb) {
    var cb = arguments[arguments.length-1];

    if (arguments.length < 2) {
      restartTimeout = undefined;
    }

    return requestGagarinConfig(true, restartTimeout).then(function (value) {
      cb(null, value);<commit_msg>Do not swallow errors from server<commit_after>
var Promise = require('es6-promise').Promise;
var util = require('util');
var tools = require('./tools');
var either = require('./tools').either;
var makeDDPClientFactory = require('./ddp');

module.exports = MeteorTransponder;

function MeteorTransponder(requestGagarinConfig) {
  "use strict";

  var self = this;

  var ddpClientAsPromise = makeDDPClientFactory(requestGagarinConfig);

  function factory(name) {
    return function (code, args) {
      var cb = arguments[arguments.length-1];

      if (arguments.length < 3) {
        args = [];
      } else {
        args = Array.isArray(args) ? args : [ args ];
      }

      //-------------------------------------------------
      return ddpClientAsPromise().then(function (ddpClient) {
        ddpClient[name](code, args, function (err) {
          cb.apply(this, arguments);
        });
      }, function (err) {
        cb(err);
      });
    }
  }

  self.promise = factory('promise');
  self.execute = factory('execute');

  self.wait = function (timeout, message, code, args) {
    var cb = arguments[arguments.length-1];

    if (arguments.length < 5) {
      args = [];
    } else {
      args = Array.isArray(args) ? args : [ args ];
    }

    //-----------------------------------------------------
    return ddpClientAsPromise().then(function (ddpClient) {
      ddpClient.wait(timeout, message, code, args, cb);
    });
  }

  self.start = function (cb) {
    return requestGagarinConfig().then(function (value) {
      cb(null, value);
    }, function (err) {
      cb(err);
    });
  };

  self.restart = function (restartTimeout) {
    var cb = arguments[arguments.length-1];

    if (arguments.length < 2) {
      restartTimeout = undefined;
    }

    return requestGagarinConfig(true, restartTimeout).then(function (value) {
      cb(null, value);
{'fraction_non_alphanumeric': 0.19427627958172813, 'fraction_numerical': 0.003852504127682994, 'mean_word_length': 2.322669104204753, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3555110', 'n_tokens_mistral': 1094, 'n_tokens_neox': 1061, 'n_words': 231}