<commit_before>/**
# Any Event

Utility methods for intercepting ANY event before anything else sees it. Note
that if you don't return true from the handler the event will be stopped.

    b8r.onAny(event_type, object, method) => handlerRef

creates an event handler that will get first access to any event; returns a
reference for purposes of removal

    b8r.offAny(handlerRef,...)

removes all the handlerRefs passed

    b8r.anyListeners()

returns active any listeners.

**Note** that this works *exactly* like an invisible element in front of
everything else for purposes of propagation.

*/
/* global module, require */
'use strict';

const {on, off, getEventHandlers} = require('./b8r.events.js');
const {create} = require('./b8r.dom.js');

const anyArgs = args => {
  var event_type, object, method, path;
  if (args.length === 2) {
    [event_type, path] = args;
  } else {
    [event_type, object, method] = args;
    path = object + '.' + method;
  }
  return {event_type, path};
};

var _anyElement = null;
const onAny = function(...args) {
  const {event_type, path} = anyArgs(args);
  if (!_anyElement) {
    _anyElement = create('div');
  }
  on(_anyElement, event_type, path);
};

const offAny = function(...args) {
  const {event_type, path} = anyArgs(args);
  if (_anyElement) {
    off(_anyElement, event_type, path);
    if (!_anyElement.getAttribute('data-event')) {
      _anyElement = null;
    }
  }
};

const anyListeners = () => anyElement ? getEventHandlers(anyElement) : [];

const anyElement = () => _anyElement;

module.exports = {
  anyListeners,<commit_msg>Fixed typo in anyListeners()<commit_after>/**
# Any Event

Utility methods for intercepting ANY event before anything else sees it. Note
that if you don't return true from the handler the event will be stopped.

    b8r.onAny(event_type, object, method) => handlerRef

creates an event handler that will get first access to any event; returns a
reference for purposes of removal

    b8r.offAny(handlerRef,...)

removes all the handlerRefs passed

    b8r.anyListeners()

returns active any listeners.

**Note** that this works *exactly* like an invisible element in front of
everything else for purposes of propagation.

*/
/* global module, require */
'use strict';

const {on, off, getEventHandlers} = require('./b8r.events.js');
const {create} = require('./b8r.dom.js');

const anyArgs = args => {
  var event_type, object, method, path;
  if (args.length === 2) {
    [event_type, path] = args;
  } else {
    [event_type, object, method] = args;
    path = object + '.' + method;
  }
  return {event_type, path};
};

var _anyElement = null;
const onAny = function(...args) {
  const {event_type, path} = anyArgs(args);
  if (!_anyElement) {
    _anyElement = create('div');
  }
  on(_anyElement, event_type, path);
};

const offAny = function(...args) {
  const {event_type, path} = anyArgs(args);
  if (_anyElement) {
    off(_anyElement, event_type, path);
    if (!_anyElement.getAttribute('data-event')) {
      _anyElement = null;
    }
  }
};

const anyListeners = () => _anyElement ? getEventHandlers(_anyElement) : [];

const anyElement = () => _anyElement;

module.exports = {
  anyListeners,
{'fraction_non_alphanumeric': 0.1307475758523616, 'fraction_numerical': 0.003753518923991242, 'mean_word_length': 3.8018018018018016, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '6237287', 'n_tokens_mistral': 1022, 'n_tokens_neox': 1016, 'n_words': 324}