Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
exotic / src / types / kind / toKindOf.ts
Size: Mime:
import { isNull, isUndefined } from '../primitive/nil'
import toObjStringTag from './toObjStringTag'
import { Kindof } from '../../../typings'

/**
 * @name toKindOf
 * @since 5.0.0-beta.9
 *
 * @param  {*} x any
 * @return {string} objectToStringTag but lowercased & stripped of brackets
 *
 * @see is/toS
 *
 * {@link https://github.com/ramda/ramda/blob/master/src/type.js ramda-type}
 * @see {@link ramda-type}
 *
 * @example toKindOf('stringy') //=> 'String'
 */
const toKindOf = (x: any, allLowerCase = undefined): Kindof => {
  const tag = isNull(x)
    ? 'Null'
    : isUndefined(x)
      ? 'Undefined'
      : toObjStringTag(x).slice(8, -1)

  return allLowerCase === true ? tag.toLowerCase() : tag
  // toObjStringTag(x).replace(/\[|\]|\s+|Object/gim, '').toLowerCase()
  // let asTag = toObjStringTag(x)
  //   .replace('[', '')
  //   .replace(']', '')
  //   .replace('object', '')
  //   .replace('Object', '')
  //   .replace(/\s+/, '')
  // // then was [object Object]
  // if (asTag === '') asTag = 'Object'
  // if (allLowerCase === true) asTag = asTag.toLowerCase()
  // return asTag
}

export { toKindOf }
export default toKindOf