<commit_before>/*****************************************************
	  https://github.com/snovakovic/wiggle
    author: <EMAIL>
    version: 0.0.1
 ***************************************************/
(function(global, factory) {
  //UMD pattern
  if (typeof exports === 'object' && typeof module !== 'undefined') {
    module.exports = factory()
  } else if (typeof define === 'function' && define.amd) {
    define(factory)
  } else {
    global.Wiggle = factory()
  }
}(this, (function() {


  return {
    init: function(settings) {
      settings.resizeDelay = settings.resizeDelay || 25;
      var screens = settings.screens;
      var doit;
      var activeScreens = [];
      var subscribeType = {
        on: 'on',
        once: 'once',
        off: 'off'
      }
      var subscribers = {};


      // Populate default subscribers
      Object.getOwnPropertyNames(subscribeType).forEach(function(name) {
        subscribers[name] = {};
      });


      window.addEventListener('resize', function() {
        clearTimeout(doit);
        doit = setTimeout(updateActiveScreens.bind(null, true), settings.resizeDelay);
      }, true);


      function updateActiveScreens(notify) {
        for (var i = 0; i < screens.length; i++) {
          var screen = screens[i];
          var active = isScreenActive(screen);

          if (active) {
            if (!activeScreens[screen.name]) {
              activeScreens[screen.name] = screen;
              notify && notifySubscribers(screen.name, subscribeType.on);
            }
          } else if (activeScreens[screen.name]) {
            delete activeScreens[screen.name];
            notify && notifySubscribers(screen.name, subscribeType.off);
          }
        }
      }

      function notifySubscribers(screenName, type) {
        var screenSubscribers = subscribers[type][screenName];
        if (screenSubscribers && screenSubscribers.length) {
          screenSubscribers.forEach(function(subscriber) {
            subscriber.execute();
          });
        }
      }

      function isScreenActive(screen) {
        if (typeof screen === 'string') {
          screen = getScreen(screen);
        }

        return Boolean(screen &&
          ((screen.minWidth && window.matchMedia('(min-width: ' + screen.minWidth + 'px)').matches) ||
            (screen.maxWidth && window.matchMedia('(max-width: ' + screen.maxWidth + 'px)').matches)));
      }

      function getScreen(name) {
        for (var i = 0; i < screens.length; i++) {
          if (name === screens[i].name) {
            return screens[i];
          }
        }
      }

      function subscribe(name, type, callback) {
        subscribers[type][name] = subscribers[type][name] || [];
        subscribers[type][name].push({
          name: name,
          type: type,
          execute: callback,<commit_msg>Fix issue with event triggered on initial load<commit_after>/*****************************************************
	  https://github.com/snovakovic/wiggle
    author: <EMAIL>
    version: 0.0.1
 ***************************************************/
(function(global, factory) {
  //UMD pattern
  if (typeof exports === 'object' && typeof module !== 'undefined') {
    module.exports = factory()
  } else if (typeof define === 'function' && define.amd) {
    define(factory)
  } else {
    global.Wiggle = factory()
  }
}(this, (function() {


  return {
    init: function(settings) {
      settings.resizeDelay = settings.resizeDelay || 25;
      var screens = Array.isArray(settings.screens) ? settings.screens : [];
      var doit;
      var activeScreens = [];
      var subscribeType = {
        on: 'on',
        once: 'once',
        off: 'off'
      }
      var subscribers = {};

      updateActiveScreens();

      // Populate default subscribers
      Object.getOwnPropertyNames(subscribeType).forEach(function(name) {
        subscribers[name] = {};
      });


      window.addEventListener('resize', function() {
        clearTimeout(doit);
        doit = setTimeout(updateActiveScreens, settings.resizeDelay);
      }, true);


      function updateActiveScreens() {
        screens.forEach(function (screen) {
          var active = isScreenActive(screen);

          if (active) {
            if (!activeScreens[screen.name]) {
              activeScreens[screen.name] = screen;
              notifySubscribers(screen.name, subscribeType.on);
            }
          } else if (activeScreens[screen.name]) {
            delete activeScreens[screen.name];
            notifySubscribers(screen.name, subscribeType.off);
          }
        });
      }

      function notifySubscribers(screenName, type) {
        var screenSubscribers = subscribers[type] && subscribers[type][screenName];
        if (screenSubscribers && screenSubscribers.length) {
          screenSubscribers.forEach(function(subscriber) {
            subscriber.execute();
          });
        }
      }

      function isScreenActive(screen) {
        if (typeof screen === 'string') {
          screen = getScreen(screen);
        }

        return Boolean(screen &&
          ((screen.minWidth && window.matchMedia('(min-width: ' + screen.minWidth + 'px)').matches) ||
            (screen.maxWidth && window.matchMedia('(max-width: ' + screen.maxWidth + 'px)').matches)));
      }

      function getScreen(name) {
        for (var i = 0; i < screens.length; i++) {
          if (name === screens[i].name) {
            return screens[i];
          }
        }
      }

      function subscribe(name, type, callback) {
        subscribers[type][name] = subscribers[type][name] || [];
        subscribers[type][name].push({
          name: name,
          type: type,
          execute: callback,
{'fraction_non_alphanumeric': 0.16721941001920057, 'fraction_numerical': 0.002269156920928609, 'mean_word_length': 2.3044982698961936, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '4382433', 'n_tokens_mistral': 1623, 'n_tokens_neox': 1544, 'n_words': 308}