<commit_before>//
// RUNTIME TYPE CHECKING
//

export {
  isArray,
  isArguments,
  isEventEmitter,
  isFunction,
  isPojo,
  isString,
  isTemplateLiteral,
  isNumber,
  isThisValue,
  isUnset,
  ArgTypeError,
  ObjTypeError
}

//
// isType
//

function isEventEmitter(obj) {
  return (
    isObject(obj) &&
    isFunction(obj.emit) &&
    (isFunction(obj.addListener) || isFunction(obj.on)) &&
    (isFunction(obj.removeListener) || isFunction(obj.off))
  )
}
isEventEmitter.displayName = 'isEventEmitter'

function isUnset(obj) {
  return obj === null || obj === undefined
}
isArray.displayName = 'isUnset'

function isArray(obj) {
  return Array.isArray(obj)
}
isArray.displayName = 'isArray'

function isArguments(obj) {
  const isObject = typeof obj === 'object'
  if (!isObject || obj === null) {
    return false
  }
  const hasMap = typeof obj.map === 'function'
  const hasLength = typeof obj.length === 'number'
  const hasObjectPrototype = obj.__proto__ === Object.prototype
  return hasObjectPrototype && isObject && hasLength && !hasMap
}
isArguments.displayName = 'isArguments'

function isFunction(obj) {
  return typeof obj === 'function'
}
isFunction.displayName = 'isFunction'

function isString(obj) {
  return typeof obj === 'string'
}
isString.displayName = 'isString'

function isNumber(obj) {
  return typeof obj === 'number'
}
isNumber.displayName = 'isNumber'

function isObject(obj) {
  return typeof obj === 'object'
}
isObject.displayName = 'isObject'

function isPojo(obj) {
  if (obj === null || !isObject(obj)) {
    return false
  }
  return Object.getPrototypeOf(obj) === Object.prototype
}
isPojo.displayName = 'isPojo'

function isTemplateLiteral(obj) {
  if (isString(obj)) {
    return true
  }
  if (!isArray(obj)) {
    return false
  }
  return obj.every(isString)
}
isTemplateLiteral.displayName = 'isTemplateLiteral'

function isThisValue(value) {
  function inObject(obj) {
    return obj === value
  }
  inObject.displayName = `isThisValue(${value})`
  return inObject
}

//
// ArgTypeError
//

const typeErrorStringIfFnReturnsFalse = (argName, argTypeFn, arg) => {
  return argTypeFn(arg)
    ? undefined
    : (argTypeFn.displayName || argTypeFn.name) +
        `(${argName}) did not return true`
}

const typeErrorStringIfTypeOfFails = (argName, argType, arg) => {
  return typeof arg === argType
    ? undefined
    : `Argument "${argName}" should be a ${argType}`
}
<commit_msg>Spacing<commit_after>//
// RUNTIME TYPE CHECKING
//

export {
  isArray,
  isArguments,
  isEventEmitter,
  isFunction,
  isPojo,
  isString,
  isTemplateLiteral,
  isNumber,
  isThisValue,
  isUnset,
  ArgTypeError,
  ObjTypeError
}

//
// isType
//

function isEventEmitter(obj) {
  return (
    isObject(obj) &&
    isFunction(obj.emit) &&
    (isFunction(obj.addListener) || isFunction(obj.on)) &&
    (isFunction(obj.removeListener) || isFunction(obj.off))
  )
}

isEventEmitter.displayName = 'isEventEmitter'

function isUnset(obj) {
  return obj === null || obj === undefined
}

isArray.displayName = 'isUnset'

function isArray(obj) {
  return Array.isArray(obj)
}

isArray.displayName = 'isArray'

function isArguments(obj) {
  const isObject = typeof obj === 'object'
  if (!isObject || obj === null) {
    return false
  }
  const hasMap = typeof obj.map === 'function'
  const hasLength = typeof obj.length === 'number'
  const hasObjectPrototype = obj.__proto__ === Object.prototype
  return hasObjectPrototype && isObject && hasLength && !hasMap
}

isArguments.displayName = 'isArguments'

function isFunction(obj) {
  return typeof obj === 'function'
}

isFunction.displayName = 'isFunction'

function isString(obj) {
  return typeof obj === 'string'
}

isString.displayName = 'isString'

function isNumber(obj) {
  return typeof obj === 'number'
}

isNumber.displayName = 'isNumber'

function isObject(obj) {
  return typeof obj === 'object'
}

isObject.displayName = 'isObject'

function isPojo(obj) {
  if (obj === null || !isObject(obj)) {
    return false
  }
  return Object.getPrototypeOf(obj) === Object.prototype
}

isPojo.displayName = 'isPojo'

function isTemplateLiteral(obj) {
  if (isString(obj)) {
    return true
  }
  if (!isArray(obj)) {
    return false
  }
  return obj.every(isString)
}

isTemplateLiteral.displayName = 'isTemplateLiteral'

function isThisValue(value) {
  function inObject(obj) {
    return obj === value
  }
  inObject.displayName = `isThisValue(${value})`
  return inObject
}

//
// ArgTypeError
//

const typeErrorStringIfFnReturnsFalse = (argName, argTypeFn, arg) => {
  return argTypeFn(arg)
    ? undefined
    : (argTypeFn.displayName || argTypeFn.name) +
        `(${argName}) did not return true`
}

const typeErrorStringIfTypeOfFails = (argName, argType, arg) => {
  return typeof arg === argType
    ? undefined
    : `Argument "${argName}" should be a ${argType}`
}

{'fraction_non_alphanumeric': 0.1345679012345679, 'fraction_numerical': 0.0, 'mean_word_length': 3.995889003083248, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '1744609', 'n_tokens_mistral': 1618, 'n_tokens_neox': 1639, 'n_words': 360}