<commit_before>import getFuncName from 'get-func-name'
import { truncator, truncate, inspectProperty, inspectList } from './helpers'

const toStringTag = typeof Symbol !== 'undefined' && Symbol.toStringTag ? Symbol.toStringTag : false

const getArrayName = array => {
  // We need to special case Node.js' Buffers, which report to be Uint8Array
  if (typeof Buffer === 'function' && array instanceof Buffer) {
    return 'Buffer'
  }
  if (toStringTag && toStringTag in array) {
    return array[toStringTag]
  }
  return getFuncName(array)
}

export default function inspectTypedArray(array, options) {
  const name = getArrayName(array)
  options.truncate -= name.length + 4
  // Object.keys will always output the Array indices first, so we can slice by
  // `array.length` to get non-index properties
  const nonIndexProperties = Object.keys(array).slice(array.length)
  if (!array.length && !nonIndexProperties.length) return `${name}[]`
  // As we know TypedArrays only contain Unsigned Integers, we can skip inspecting each one and simply
  // stylise the toString() value of them
  let output = ''
  for (const i of array) {
    const string = `${options.stylize(truncate(i, options.truncate), 'number')}${i === array.length ? '' : ', '}`
    options.truncate -= string.length
    if (i !== array.length && options.truncate <= 3) {
      output += `${truncator}(${array.length - i + 1})`
      break<commit_msg>fix(typedarray): getFuncName(array) return null<commit_after>import getFuncName from 'get-func-name'
import { truncator, truncate, inspectProperty, inspectList } from './helpers'

const toStringTag = typeof Symbol !== 'undefined' && Symbol.toStringTag ? Symbol.toStringTag : false

const getArrayName = array => {
  // We need to special case Node.js' Buffers, which report to be Uint8Array
  if (typeof Buffer === 'function' && array instanceof Buffer) {
    return 'Buffer'
  }
  if (toStringTag && toStringTag in array) {
    return array[toStringTag]
  }
  return getFuncName(array.constructor)
}

export default function inspectTypedArray(array, options) {
  const name = getArrayName(array)
  options.truncate -= name.length + 4
  // Object.keys will always output the Array indices first, so we can slice by
  // `array.length` to get non-index properties
  const nonIndexProperties = Object.keys(array).slice(array.length)
  if (!array.length && !nonIndexProperties.length) return `${name}[]`
  // As we know TypedArrays only contain Unsigned Integers, we can skip inspecting each one and simply
  // stylise the toString() value of them
  let output = ''
  for (const i of array) {
    const string = `${options.stylize(truncate(i, options.truncate), 'number')}${i === array.length ? '' : ', '}`
    options.truncate -= string.length
    if (i !== array.length && options.truncate <= 3) {
      output += `${truncator}(${array.length - i + 1})`
      break
{'fraction_non_alphanumeric': 0.12690707350901526, 'fraction_numerical': 0.0027739251040221915, 'mean_word_length': 3.98272884283247, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1409595', 'n_tokens_mistral': 850, 'n_tokens_neox': 845, 'n_words': 274}