<commit_before>// Copyright 2002-2013, University of Colorado Boulder

/**
 * Timer so that other modules can run timing related code through the simulation's requestAnimationFrame.
 * Note: this is not specific to the running screen, it is global across all screens.
 *
 * @author <NAME>
 */
define( function() {
  'use strict';
  var listeners = [];
  return {

    //Trigger a step event, called by Sim.js in the animation loop
    step: function( dt ) {
      var length = listeners.length;
      for ( var i = 0; i < length; i++ ) {
        listeners[i]( dt );
      }
    },

    //Add a listener to be called back once after the specified time (in milliseconds)
    setTimeout: function( listener, timeout ) {
      var elapsed = 0;
      var timer = this;
      var callback = function( dt ) {
        elapsed += dt;

        //Convert seconds to ms and see if item has timed out
        if ( elapsed * 1000 >= timeout ) {
          listener();
          timer.removeStepListener( callback );
        }
      };
      this.addStepListener( callback );

      //Return the callback so it can be removed with removeStepListener
      return callback;
    },

    //Clear a scheduled timeout
    clearTimeout: function( timeoutID ) { this.removeStepListener( timeoutID ); },

    setInterval: function( listener, timeout ) {
      var elapsed = 0;
      var callback = function( dt ) {
        elapsed += dt;

        //Convert seconds to ms and see if item has timed out
        if ( elapsed * 1000 >= timeout ) {
          listener();
          elapsed = elapsed - timeout / 1000.0;//Save the leftover time so it won't accumulate
        }
      };
      this.addStepListener( callback );

      //Return the callback so it can be removed with removeStepListener
      return callback;
    },

    clearInterval: function( id ) { this.removeStepListener( id ); },

    //Add a listener to be called back on every animationFrame with a dt value
    addStepListener: function( listener ) { listeners.push( listener ); },

    //Remove a step listener from being called back
    removeStepListener: function( listener ) {
      var index = listeners.indexOf( listener );
      if ( index !== -1 ) {
        listeners.splice( index, 1 );
      }
    }
  };
} );<commit_msg>#104, fixes to joist.Timer doc and naming<commit_after>// Copyright 2002-2013, University of Colorado Boulder

/**
 * Timer so that other modules can run timing related code through the simulation's requestAnimationFrame.
 * Note: this is not specific to the running screen, it is global across all screens.
 *
 * @author <NAME>
 */
define( function() {
  'use strict';
  var listeners = [];
  return {

    //Trigger a step event, called by Sim.js in the animation loop
    step: function( dt ) {
      var length = listeners.length;
      for ( var i = 0; i < length; i++ ) {
        listeners[i]( dt );
      }
    },

    //Add a listener to be called back once after the specified time (in milliseconds)
    setTimeout: function( listener, timeout ) {
      var elapsed = 0;
      var timer = this;
      var callback = function( dt ) {
        elapsed += dt;

        //Convert seconds to ms and see if item has timed out
        if ( elapsed * 1000 >= timeout ) {
          listener();
          timer.removeStepListener( callback );
        }
      };
      this.addStepListener( callback );

      //Return the callback so it can be removed with removeStepListener
      return callback;
    },

    //Clear a scheduled timeout
    clearTimeout: function( timeoutID ) { this.removeStepListener( timeoutID ); },

    //Add a listener to be called at specified intervals (in milliseconds)
    setInterval: function( listener, interval ) {
      var elapsed = 0;
      var callback = function( dt ) {
        elapsed += dt;

        //Convert seconds to ms and see if item has timed out
        if ( elapsed * 1000 >= interval ) {
          listener();
          elapsed = elapsed - interval / 1000.0;//Save the leftover time so it won't accumulate
        }
      };
      this.addStepListener( callback );

      //Return the callback so it can be removed with removeStepListener
      return callback;
    },

    //Clear a scheduled interval
    clearInterval: function( intervalID ) { this.removeStepListener( intervalID ); },

    //Add a listener to be called back on every animationFrame with a dt value
    addStepListener: function( listener ) { listeners.push( listener ); },

    //Remove a step listener from being called back
    removeStepListener: function( listener ) {
      var index = listeners.indexOf( listener );
      if ( index !== -1 ) {
        listeners.splice( index, 1 );
      }
    }
  };
} );
{'fraction_non_alphanumeric': 0.09538984491183344, 'fraction_numerical': 0.011684724877841512, 'mean_word_length': 2.336640680368533, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '5577200', 'n_tokens_mistral': 1294, 'n_tokens_neox': 1196, 'n_words': 503}