<commit_before>/**
*  JavaScript Events
*
*  A collection of functions to be used with events.
*
*  E.g. The KeyPress event has different implementations accross browsers, so
*  this class contains methods to polyfill this functionality to ensure a standardised
*  implementation between browsers
*
*  @class Events
**/
class Events {

  /**
  * A method to determine if an event is of a particular type
  *
  * @method isEventType
  * @params {Event} ev A JavaScript event
  * @params {Type} type A JavaScript event type
  * @returns {Boolean}
  **/
  static isEventType = (ev, type) => {
    return ev.type == type;
  };

  /**
  * A method to determine whether a key down event was an arrow key
  *
  * @method isNavigationKeyup
  * @params {Event} ev A JavaScript event
  * @returns {Boolean}
  **/
  static isNavigationKeyup = (ev) => {
    if (!Events.isEventType(ev, "keyup")) {
      return false;
    }

    return Events.isNavigationKey(ev);
  };

  /**
  * A method to determine whether a key down event was an enter key
  *
  * @method isEnterKeyup
  * @params {Event} ev A JavaScript event
  * @returns {Boolean}
  **/
  static isEnterKeyup = (ev) => {
    if (!Events.isEventType(ev, "keyup")) {
      return false;
    }

    return Events.isEnterKey(ev);
  };

  /**
  * A method to determine whether a key up event is allowed or not.
  *
  * @method isValidKeypress
  * @params {Event} ev A JavaScript event
  * @returns {Boolean}
  **/
  static isValidKeypress = (ev) => {
    if (!Events.isEventType(ev, "keyup")) {
      return false;
    }
    if (Events.isNumberKey(ev) ||
        Events.isAlphabetKey(ev) ||
        Events.isNumpadKey(ev) ||
        Events.isSymbolKey(ev) ||
        Events.isSpaceKey(ev) ||
        Events.isDeletingKey(ev) ||
        Events.isBackspaceKey(ev)) {
      return true;
    }

    return false;
  };

  /**
  * Determines if a number key along the top of the keyboard or a number key on the
  * keypad is pressed
  *
  * @method isNumberKey
  * @params {Event} ev A JavaScript event
  * @returns {Boolean}
  **/
  static isNumberKey = (ev) => {
    return ev.which >= 48 && ev.which <= 57 || ev.which >= 96 && ev.which <= 105;
  };

  /**
  * Determines if the key pressed is part of the numpad
  * includes symbols
  *
  * @method isNumberKey
  * @params {Event} ev A JavaScript event
  * @returns {Boolean}
  **/
  static isNumpadKey = (ev) => {
    return ev.which >= 96 && ev.which <= 111;
  };

  /**
  * Determines if the key pressed is a alphabet key
  * Case insensitive
  *
  * @method isAlphasbetKey
  * @params {Event} ev A JavaScript event
  * @returns {Boolean}
  **/
  static isAlphabetKey = (ev) => {
    return ev.which >= 65 && ev.which <= 90;
  };
<commit_msg>fix typo in events helper<commit_after>/**
*  JavaScript Events
*
*  A collection of functions to be used with events.
*
*  E.g. The KeyPress event has different implementations accross browsers, so
*  this class contains methods to polyfill this functionality to ensure a standardised
*  implementation between browsers
*
*  @class Events
**/
class Events {

  /**
  * A method to determine if an event is of a particular type
  *
  * @method isEventType
  * @params {Event} ev A JavaScript event
  * @params {Type} type A JavaScript event type
  * @returns {Boolean}
  **/
  static isEventType = (ev, type) => {
    return ev.type == type;
  };

  /**
  * A method to determine whether a key down event was an arrow key
  *
  * @method isNavigationKeyup
  * @params {Event} ev A JavaScript event
  * @returns {Boolean}
  **/
  static isNavigationKeyup = (ev) => {
    if (!Events.isEventType(ev, "keyup")) {
      return false;
    }

    return Events.isNavigationKey(ev);
  };

  /**
  * A method to determine whether a key down event was an enter key
  *
  * @method isEnterKeyup
  * @params {Event} ev A JavaScript event
  * @returns {Boolean}
  **/
  static isEnterKeyup = (ev) => {
    if (!Events.isEventType(ev, "keyup")) {
      return false;
    }

    return Events.isEnterKey(ev);
  };

  /**
  * A method to determine whether a key up event is allowed or not.
  *
  * @method isValidKeypress
  * @params {Event} ev A JavaScript event
  * @returns {Boolean}
  **/
  static isValidKeypress = (ev) => {
    if (!Events.isEventType(ev, "keyup")) {
      return false;
    }
    if (Events.isNumberKey(ev) ||
        Events.isAlphabetKey(ev) ||
        Events.isNumpadKey(ev) ||
        Events.isSymbolKey(ev) ||
        Events.isSpaceKey(ev) ||
        Events.isDeletingKey(ev) ||
        Events.isBackspaceKey(ev)) {
      return true;
    }

    return false;
  };

  /**
  * Determines if a number key along the top of the keyboard or a number key on the
  * keypad is pressed
  *
  * @method isNumberKey
  * @params {Event} ev A JavaScript event
  * @returns {Boolean}
  **/
  static isNumberKey = (ev) => {
    return ev.which >= 48 && ev.which <= 57 || ev.which >= 96 && ev.which <= 105;
  };

  /**
  * Determines if the key pressed is part of the numpad
  * includes symbols
  *
  * @method isNumberKey
  * @params {Event} ev A JavaScript event
  * @returns {Boolean}
  **/
  static isNumpadKey = (ev) => {
    return ev.which >= 96 && ev.which <= 111;
  };

  /**
  * Determines if the key pressed is a alphabet key
  * Case insensitive
  *
  * @method isAlphabetKey
  * @params {Event} ev A JavaScript event
  * @returns {Boolean}
  **/
  static isAlphabetKey = (ev) => {
    return ev.which >= 65 && ev.which <= 90;
  };

{'fraction_non_alphanumeric': 0.12383561643835617, 'fraction_numerical': 0.006575342465753425, 'mean_word_length': 2.7378839590443684, 'pattern_counts': {'":': 0, '<': 11, '<?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': '1765235', 'n_tokens_mistral': 1833, 'n_tokens_neox': 1759, 'n_words': 578}