export const isBoolean = (arg: unknown) => typeof arg === 'boolean'
export const isNumber = (arg: unknown) => typeof arg === 'number' && Number.isFinite(arg)

export const isEmpty = (string: string) => !!string.trim()

export function debounce(callback: (...args: any) => void, timeout = 300) {
  let timer: ReturnType<typeof setTimeout>
  return (...args: any) => {
    clearTimeout(timer)
    timer = setTimeout(() => {
      // @ts-ignore
      callback.apply(this, args)
    }, timeout)
  }
}
