import { debounce } from 'lodash'
import { createSafe } from '@esdora/kit'

const safe = createSafe((err) => {
  console.log(`发生错误: ${err}`)
})

export function Debounce(ms: number) {
  return function (target: any, propertyKey: string, descriptor: PropertyDescriptor) {
    descriptor.value = debounce(descriptor.value, ms)
  }
}

export function Safe(target: any, propertyKey: string, descriptor: PropertyDescriptor) {
  descriptor.value = safe(descriptor.value)
}
