<commit_before>/// <reference path='promise.ts'/>

namespace Mist {

  /**
  * @class Frame
  * @summary queuer
  */
  export class Frame {

    private static txg: boolean;
    private static txs: (() => boolean)[] = [];

    /**
    * @access public
    * @static
    * @summary milliseconds per frame
    */
    static mspf: number = 1000 / 60;

    /**
    * @access public
    * @static
    * @summary timestamp
    */
    static times: number = 0;

    /**
    * @param {} responsor
    * @param {} delay
    */
    static at(responsor: () => void, delay: number = 0) {

      // queues.
      this.txs.push(

        function() {

          var r = 0 > delay--;

          if (r) {

            // commit response.
            responsor();
          }

          return r;
        });

      this.tx();
    }

    /**
    * @param {} responsor
    * @param {} delay
    * @return {}
    */
    static on(responsor: () => any, delay: number = 0): Promise {

      return new Promise((

        succeed,
        erred
        ) => {

        // queues.
        this.txs.push(

          function() {

            var r = 0 > delay--;

            if (r) {

              try {
                // commit response.
                succeed(responsor());

              } catch (e) {

                // fail response.
                erred(e);
              }
            }

            return r;
          });

        this.tx();
      });
    }

    /**
    * @access private
    * @static
    */
    private static enter(responsor: FrameRequestCallback) {

      var s = this;
      var t = Date.now();

      // filt response.

      if (t - s.times > s.mspf) {

        s.times = t;

      } else {
        // no response.

        responsor = s.enter.bind(s, responsor);
      }

      requestAnimationFrame(responsor);
    }

    /**
    * @access private
    * @static
    */
    private static tx() {

      this.txg || (() => {
        this.txg = true;

        var s = this;

        (function composer() {

          // initialize.

          var o: (() => boolean)[] = [];

          var responsor: () => boolean;

          while (

            responsor = s.txs.shift()) {
            responsor() || o.push(responsor);
          }

          if (s.txg =
            s.txs.push.apply(
              s.txs, o) > 0) {

            s.enter(composer);
          }
        })();
      })();
    }
  }
}<commit_msg>refactor for performance.<commit_after>/// <reference path='promise.ts'/>

namespace Mist {

  /**
  * @class Frame
  * @summary queuer
  */
  export class Frame {

    private static txg: boolean;
    private static txs: (() => boolean)[] = [];

    /**
    * @param {} responsor
    * @param {} delay
    */
    static at(responsor: () => void, delay: number = 0) {

      this.txs.push(

        function() {

          var r = 0 > delay--;

          if (r) {

            // commit response.
            responsor();
          }

          return r;
        });

      this.tx();
    }

    /**
    * @param {} responsor
    * @param {} delay
    */
    static on(responsor: () => any, delay: number = 0): Promise {

      return new Promise((

        succeed,
        erred
        ) => {

        this.txs.push(

          function() {

            var r = 0 > delay--;

            if (r) {

              try {
                // commit response.
                succeed(responsor());

              } catch (e) {

                // fail response.
                erred(e);
              }
            }

            return r;
          });

        this.tx();
      });
    }

    /**
    * @access private
    * @static
    */
    private static tx() {

      this.txg || (() => {
        this.txg = true;

        var s = this;

        (function composer() {

          // initialize.

          var o: (() => boolean)[] = [];

          var responsor: () => boolean;

          while (

            responsor = s.txs.shift()) {
            responsor() || o.push(responsor);
          }

          if (s.txg =
            !!s.txs.push.apply(
              s.txs, o)) {

            requestAnimationFrame(composer);
          }
        })();
      })();
    }
  }
}
{'fraction_non_alphanumeric': 0.15080875356803045, 'fraction_numerical': 0.003805899143672693, 'mean_word_length': 1.0899602385685885, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, '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': '5134592', 'n_tokens_mistral': 1328, 'n_tokens_neox': 1224, 'n_words': 279}