<commit_before>import {EVENT_CATCH_EM_ALL} from './constants';
import {EventName} from './types';

export const isCatchEmAll = (eventName: unknown): eventName is string =>
  eventName === EVENT_CATCH_EM_ALL;

export const isEventName = (eventName: unknown): eventName is EventName => {
  switch (typeof eventName) {
    case 'string':
    case 'symbol':
      return true;
    default:
      return false;
  }
};<commit_msg>convert logUtils and propUtils to typescript<commit_after>/* eslint-disable no-console */
import {LOG_NAMESPACE, EVENT_CATCH_EM_ALL} from './constants';
import {EventName} from './types';

export const isCatchEmAll = (eventName: unknown): eventName is string =>
  eventName === EVENT_CATCH_EM_ALL;

export const isEventName = (eventName: unknown): eventName is EventName => {
  switch (typeof eventName) {
    case 'string':
    case 'symbol':
      return true;
    default:
      return false;
  }
};

export const hasConsole = typeof console !== 'undefined';

export const warn = hasConsole
  ? console[console.warn ? 'warn' : 'log'].bind(console, LOG_NAMESPACE)
  : () => {};

type PropertyKey = string | symbol;
type PropertyValue = any;

export const definePublicPropertyRO = <T extends Object>(
  obj: T,
  name: PropertyKey,
  value: PropertyValue,
): T => {
  Object.defineProperty(obj, name, {
    value,
    configurable: true,
    enumerable: true,
  });
  return obj;
};

export const definePublicPropertiesRO = <T extends Object>(
  obj: T,
  attrs: Record<PropertyKey, PropertyValue>,
): T => {
  const keys = Object.keys(attrs);
  const len = keys.length;
  for (let i = 0; i < len; i += 1) {
    definePublicPropertyRO(obj, keys[i], attrs[keys[i]]);
  }
  return obj;
};

export const defineHiddenPropertyRO = <T extends Object>(
  obj: T,
  name: PropertyKey,
  value: PropertyValue,
): T => {
  Object.defineProperty(obj, name, {
    value,
    configurable: true,
  });
  return obj;
};
{'fraction_non_alphanumeric': 0.1305699481865285, 'fraction_numerical': 0.0010362694300518134, 'mean_word_length': 3.9512820512820515, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 15, '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': '7167766', 'n_tokens_mistral': 609, 'n_tokens_neox': 611, 'n_words': 179}