<commit_before>/*
 * Copyright 2009 <NAME> (<EMAIL>)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
*/
if (typeof fleegix == 'undefined') { var fleegix = {}; }
if (typeof fleegix.event == 'undefined') {
  throw('fleegix.event.delegator depends on the base fleegix.event module in fleegix.js.'); }

fleegix.event.Periodic = function (func, interval, waitFirst) {
  var _this = this;
  var _paused = false;
  this.func = func || null;
  this.interval = interval || null;
  this.waitFirst = waitFirst || false;
  this.start = function (waitFirst) {
    this.waitFirst = waitFirst || this.waitFirst;
    if (this.waitFirst) {
      setTimeout(this.run, this.interval);
    }
    else {
      this.run();
    }
  };
  this.run = function () {
    if (!_paused) {
      _this.func();
      setTimeout(_this.run, _this.interval);
    }
  };
  this.pause = function () {
    _paused = true;
  };
  this.resume = function () {
    _paused = false;
    this.run();
  };
};

// Clean up listeners
fleegix.event.listen(window, 'onunload', function () {
  try {
    fleegix.event.flush();
  }
  catch (e) {} // Squelch
});

<commit_msg>Allow execution context to be passed into the periodic executor.<commit_after>/*
 * Copyright 2009 <NAME> (<EMAIL>@fleegix.org)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
*/
if (typeof fleegix == 'undefined') { var fleegix = {}; }
if (typeof fleegix.event == 'undefined') {
  throw('fleegix.event.delegator depends on the base fleegix.event module in fleegix.js.'); }

fleegix.event.Periodic = function () {
  var _this = this;
  var _paused = false;

  var args = Array.prototype.slice.apply(arguments);
  var context;
  var methodName;
  if (typeof args[0] != 'function') {
    context = args.shift();
    methodName = args.shift();
  }
  else {
    var func = args.shift();
  }
  var interval = args.shift();
  var waitFirst = args.shift();

  this.context = context || null;
  this.methodName = methodName || null;
  this.func = func || null;
  this.interval = interval || null;
  this.waitFirst = waitFirst || false;
  this.start = function (waitFirst) {
    this.waitFirst = waitFirst || this.waitFirst;
    if (this.waitFirst) {
      setTimeout(this.run, this.interval);
    }
    else {
      this.run();
    }
  };
  this.run = function () {
    if (!_paused) {
      if (_this.context) {
        _this.context[_this.methodName].call(_this.context);
      }
      else {
        _this.func();
      }
      setTimeout(_this.run, _this.interval);
    }
  };
  this.pause = function () {
    _paused = true;
  };
  this.resume = function () {
    _paused = false;
    this.run();
  };
};

// Clean up listeners
fleegix.event.listen(window, 'onunload', function () {
  try {
    fleegix.event.flush();
  }
  catch (e) {} // Squelch
});


{'fraction_non_alphanumeric': 0.13148880105401844, 'fraction_numerical': 0.0044795783926218705, 'mean_word_length': 3.0340063761955367, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '7454934', 'n_tokens_mistral': 1203, 'n_tokens_neox': 1183, 'n_words': 363}