basic.ts 414 B

1234567891011
  1. export const objectToString = Object.prototype.toString
  2. export const toTypeString = (value: unknown): string => objectToString.call(value)
  3. export const toRawType = (value: unknown): string => {
  4. // extract "RawType" from strings like "[object RawType]"
  5. return toTypeString(value).slice(8, -1)
  6. }
  7. export const isString = <T>(value: T): T extends string ? true : false => (toRawType(value) === 'String') as any