<commit_before>angular.module('npact')
  .factory('Utils', function($q, $timeout, $log, $interval) {
    'use strict';
    // sigil value for quitting forEachAsync
    var STOP_ITERATING = {},
        log10 = Math.log(10);
    // public interface
    return {
      STOP_ITERATING: STOP_ITERATING,
      orderOfMagnitude: orderOfMagnitude,
      forEachAsync: forEachAsync,
      widthAvailable: widthAvailable
    };

    /**
     * find the nearest order of magnitude to `x`
     *
     * orderOfMagnitude(1012) => 1000
     * orderOfMagnitude(1012, -1) => 100
     *
     * @param {Number} x
     * @param {Number} [exponent] shift the result by this many digits
     */
    function orderOfMagnitude(x, exponent){
      return Math.pow(10, Math.round(Math.log(x) / log10) + (exponent || 0));
    }


    /**
     * polls for when the element has a width
     *
     * @param {Element} element - what element to scan
     * @returns {Promise} - the width of the element
     */
    function widthAvailable(element){
      var d = $q.defer(),
          p = d.promise,
          t1 = new Date(),
          task = $interval(checkForWidth, 100);
      // stop polling once we've found a value
      p.then(function(){$interval.cancel(task);});
      return p;

      function checkForWidth(){
        var w = element.width();
        // indicate progress via the promise
        d.notify(new Date() - t1);
        if(w > 0){
          d.resolve(w);
        }
      }
    }

    /**
     * Loop over the list from back to front, asyncronously<commit_msg>delete dead code<commit_after>angular.module('npact')
  .factory('Utils', function($q, $timeout, $log, $interval) {
    'use strict';
    // sigil value for quitting forEachAsync
    var STOP_ITERATING = {},
        log10 = Math.log(10);
    // public interface
    return {
      STOP_ITERATING: STOP_ITERATING,
      orderOfMagnitude: orderOfMagnitude,
      forEachAsync: forEachAsync
    };

    /**
     * find the nearest order of magnitude to `x`
     *
     * orderOfMagnitude(1012) => 1000
     * orderOfMagnitude(1012, -1) => 100
     *
     * @param {Number} x
     * @param {Number} [exponent] shift the result by this many digits
     */
    function orderOfMagnitude(x, exponent){
      return Math.pow(10, Math.round(Math.log(x) / log10) + (exponent || 0));
    }

    /**
     * Loop over the list from back to front, asyncronously
{'fraction_non_alphanumeric': 0.12421842434347645, 'fraction_numerical': 0.02334305960817007, 'mean_word_length': 2.314917127071823, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, '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': '4813062', 'n_tokens_mistral': 801, 'n_tokens_neox': 730, 'n_words': 204}