|  | 
| 1 |  | -export function kindOf(val) { | 
| 2 |  | -  let typeOfVal = typeof val | 
|  | 1 | +// Inlined / shortened version of `kindOf` from https://github.com/jonschlinkert/kind-of | 
|  | 2 | +function miniKindOf(val) { | 
|  | 3 | +  if (val === void 0) return 'undefined' | 
|  | 4 | +  if (val === null) return 'null' | 
| 3 | 5 | 
 | 
| 4 |  | -  if (process.env.NODE_ENV !== 'production') { | 
| 5 |  | -    // Inlined / shortened version of `kindOf` from https://github.com/jonschlinkert/kind-of | 
| 6 |  | -    function miniKindOf(val) { | 
| 7 |  | -      if (val === void 0) return 'undefined' | 
| 8 |  | -      if (val === null) return 'null' | 
|  | 6 | +  const type = typeof val | 
|  | 7 | +  switch (type) { | 
|  | 8 | +    case 'boolean': | 
|  | 9 | +    case 'string': | 
|  | 10 | +    case 'number': | 
|  | 11 | +    case 'symbol': | 
|  | 12 | +    case 'function': { | 
|  | 13 | +      return type | 
|  | 14 | +    } | 
|  | 15 | +    default: | 
|  | 16 | +      break | 
|  | 17 | +  } | 
| 9 | 18 | 
 | 
| 10 |  | -      const type = typeof val | 
| 11 |  | -      switch (type) { | 
| 12 |  | -        case 'boolean': | 
| 13 |  | -        case 'string': | 
| 14 |  | -        case 'number': | 
| 15 |  | -        case 'symbol': | 
| 16 |  | -        case 'function': { | 
| 17 |  | -          return type | 
| 18 |  | -        } | 
| 19 |  | -        default: | 
| 20 |  | -          break | 
| 21 |  | -      } | 
|  | 19 | +  if (Array.isArray(val)) return 'array' | 
|  | 20 | +  if (isDate(val)) return 'date' | 
|  | 21 | +  if (isError(val)) return 'error' | 
| 22 | 22 | 
 | 
| 23 |  | -      if (Array.isArray(val)) return 'array' | 
| 24 |  | -      if (isDate(val)) return 'date' | 
| 25 |  | -      if (isError(val)) return 'error' | 
|  | 23 | +  const constructorName = ctorName(val) | 
|  | 24 | +  switch (constructorName) { | 
|  | 25 | +    case 'Symbol': | 
|  | 26 | +    case 'Promise': | 
|  | 27 | +    case 'WeakMap': | 
|  | 28 | +    case 'WeakSet': | 
|  | 29 | +    case 'Map': | 
|  | 30 | +    case 'Set': | 
|  | 31 | +      return constructorName | 
|  | 32 | +    default: | 
|  | 33 | +      break | 
|  | 34 | +  } | 
| 26 | 35 | 
 | 
| 27 |  | -      const constructorName = ctorName(val) | 
| 28 |  | -      switch (constructorName) { | 
| 29 |  | -        case 'Symbol': | 
| 30 |  | -        case 'Promise': | 
| 31 |  | -        case 'WeakMap': | 
| 32 |  | -        case 'WeakSet': | 
| 33 |  | -        case 'Map': | 
| 34 |  | -        case 'Set': | 
| 35 |  | -          return constructorName | 
| 36 |  | -        default: | 
| 37 |  | -          break | 
| 38 |  | -      } | 
|  | 36 | +  // other | 
|  | 37 | +  return type.slice(8, -1).toLowerCase().replace(/\s/g, '') | 
|  | 38 | +} | 
| 39 | 39 | 
 | 
| 40 |  | -      // other | 
| 41 |  | -      return type.slice(8, -1).toLowerCase().replace(/\s/g, '') | 
| 42 |  | -    } | 
|  | 40 | +function ctorName(val) { | 
|  | 41 | +  return typeof val.constructor === 'function' ? val.constructor.name : null | 
|  | 42 | +} | 
| 43 | 43 | 
 | 
| 44 |  | -    function ctorName(val) { | 
| 45 |  | -      return typeof val.constructor === 'function' ? val.constructor.name : null | 
| 46 |  | -    } | 
|  | 44 | +function isError(val) { | 
|  | 45 | +  return ( | 
|  | 46 | +    val instanceof Error || | 
|  | 47 | +    (typeof val.message === 'string' && | 
|  | 48 | +      val.constructor && | 
|  | 49 | +      typeof val.constructor.stackTraceLimit === 'number') | 
|  | 50 | +  ) | 
|  | 51 | +} | 
| 47 | 52 | 
 | 
| 48 |  | -    function isError(val) { | 
| 49 |  | -      return ( | 
| 50 |  | -        val instanceof Error || | 
| 51 |  | -        (typeof val.message === 'string' && | 
| 52 |  | -          val.constructor && | 
| 53 |  | -          typeof val.constructor.stackTraceLimit === 'number') | 
| 54 |  | -      ) | 
| 55 |  | -    } | 
|  | 53 | +function isDate(val) { | 
|  | 54 | +  if (val instanceof Date) return true | 
|  | 55 | +  return ( | 
|  | 56 | +    typeof val.toDateString === 'function' && | 
|  | 57 | +    typeof val.getDate === 'function' && | 
|  | 58 | +    typeof val.setDate === 'function' | 
|  | 59 | +  ) | 
|  | 60 | +} | 
| 56 | 61 | 
 | 
| 57 |  | -    function isDate(val) { | 
| 58 |  | -      if (val instanceof Date) return true | 
| 59 |  | -      return ( | 
| 60 |  | -        typeof val.toDateString === 'function' && | 
| 61 |  | -        typeof val.getDate === 'function' && | 
| 62 |  | -        typeof val.setDate === 'function' | 
| 63 |  | -      ) | 
| 64 |  | -    } | 
|  | 62 | +export function kindOf(val) { | 
|  | 63 | +  let typeOfVal = typeof val | 
| 65 | 64 | 
 | 
|  | 65 | +  if (process.env.NODE_ENV !== 'production') { | 
| 66 | 66 |     typeOfVal = miniKindOf(val) | 
| 67 | 67 |   } | 
| 68 | 68 | 
 | 
|  | 
0 commit comments