import _typeof from "@babel/runtime/helpers/esm/typeof";

/**
 * isType.js
 *
 * @Author: jruif
 * @Date: 2017/7/6 下午10:28
 */
export var toFirstUpperCase = function toFirstUpperCase(target) {
  if (typeof target !== 'string') {
    return console.warn('target must be string');
  }

  return target.replace(/^\w/, function (a) {
    return a.toUpperCase();
  });
};
var isBaseType = ['string', 'number', 'undefined', 'boolean', 'symbol'].reduce(function (result, type) {
  result[type] = function (obj) {
    return _typeof(obj) === type;
  };

  return result;
}, {});
export var isString = isBaseType.string;
export var isNumber = isBaseType.number;
export var isUndefined = isBaseType.undefined;
export var isBoolean = isBaseType.boolean;
export var isSymbol = isBaseType.symbol;
export var isObject = function isObject(obj) {
  return Object.prototype.toString.call(obj) === "[object Object]";
};
export var isFunction = function isFunction(obj) {
  return Object.prototype.toString.call(obj) === "[object Function]";
};
export var isNull = function isNull(obj) {
  return obj === null;
};
export var hasChildren = function hasChildren(child) {
  return Array.isArray(child) && child.length > 0 || !isNull(child) && !isUndefined(child);
};
export default {
  isString: isString,
  isNumber: isNumber,
  isUndefined: isUndefined,
  isBoolean: isBoolean,
  isSymbol: isSymbol,
  isObject: isObject,
  isFunction: isFunction,
  isNull: isNull,
  hasChildren: hasChildren
};