type Types =
  | 'Number'
  | 'String'
  | 'Boolean'
  | 'Null'
  | 'Undefined'
  | 'Array'
  | 'Object';

export const getType = function (value: any): Types {
  const typeofs = Object.prototype.toString.call(value);

  switch (typeofs) {
    case '[object Number]':
      return 'Number'; // NaN Infinity 也是Number类型

    case '[object String]':
      return 'String';

    case '[object Boolean]':
      return 'Boolean';

    case '[object Null]':
      return 'Null';

    case '[object Undefined]':
      return 'Undefined';

    case '[object Array]':
      return 'Array';

    case '[object Object]':
      return 'Object';

    default:
      return typeofs as any;
  }
};
