<commit_before>"use strict";

const defer      = require('../promise/defer');
const isNumber   = require('mout/lang/isNumber');

module.exports =  function(fn, timeout) {
  if(!timeout)
    return fn;

  if(!isNumber(timeout))
    throw "timeout must be a number";

  var my = function* () {
    var args = [].slice.call(arguments);

    var defered = defer();

    setTimeout(defered.reject.bind(defered, "timeout"), timeout);

    yield [ function*() {
      var response = yield fn(args);
      defered.resolve(response);
    }, defered];

    return defered;
  }
  return my;
}<commit_msg>run function with correct arguments<commit_after>"use strict";

const defer      = require('../promise/defer');
const isNumber   = require('mout/lang/isNumber');

module.exports =  function(fn, timeout) {
  if(!timeout)
    return fn;

  if(!isNumber(timeout))
    throw "timeout must be a number";

  var my = function* () {
    var args = [].slice.call(arguments);
    var self = this;
    var defered = defer();

    setTimeout(defered.reject.bind(defered, "timeout"), timeout);

    yield [ function*() {
      var response = yield fn.applay(self, args);
      defered.resolve(response);
    }, defered];

    return defered;
  }
  return my;
}
{'fraction_non_alphanumeric': 0.1498791297340854, 'fraction_numerical': 0.0, 'mean_word_length': 3.195945945945946, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3472746', 'n_tokens_mistral': 406, 'n_tokens_neox': 383, 'n_words': 98}