Skip to content

utils

isObject

ts
export const isObject = (value: unknown): value is Record<any, any> =>
  value !== null && typeof value === 'object'

isFunction

ts
export const isFunction = (value: unknown): value is (...args: any) => any =>
  typeof value === 'function'

isString

ts
export const isString = (value: unknown): value is string => typeof value === 'string'

isBoolean

ts
export const isBoolean = (value: unknown): value is boolean => typeof value === 'boolean'

isNumber

ts
export const isNumber = (value: unknown): value is number => typeof value === 'number'

isUndef

ts
export const isUndef = (value: unknown): value is undefined => typeof value === 'undefined'

isBrowser

ts
const isBrowser = !!(
  typeof window !== 'undefined' &&
  window.document &&
  window.document.createElement
)

isDev

ts
const isDev = process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test'

如有转载或 CV 的请标注本站原文地址