File size: 597 Bytes
369fac9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import getFuncName from 'get-func-name'
import inspectObject from './object'

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

export default function inspectClass(value, options) {
  let name = ''
  if (toStringTag && toStringTag in value) {
    name = value[toStringTag]
  }
  name = name || getFuncName(value.constructor)
  // Babel transforms anonymous classes to the name `_class`
  if (!name || name === '_class') {
    name = '<Anonymous Class>'
  }
  options.truncate -= name.length
  return `${name}${inspectObject(value, options)}`
}