export const warn = (condition: unknown, message: string) => { if (condition) { console.warn(`[@datago/components]: `, message) } } export const deprecatedWarn = (prop: string, message: string, replace = true) => { warn(true, `属性 [${prop}] 已弃用,${replace ? `请使用属性 [${message}] 代替!` : message}`) } export const debounce = (fn: (...args: any[]) => void, n = 100) => { let handle: any return (...args: any[]) => { if (handle) clearTimeout(handle) handle = setTimeout(() => { fn(...args) }, n) } } const hasOwnProperty = Object.prototype.hasOwnProperty export const hasOwn = (obj: object, key: keyof any) => hasOwnProperty.call(obj, key) export const omitFormNill = (form) => { const res = {} for (const key in form) { if (hasOwn(form, key)) { const value = form[key] if (!['', null, undefined].includes(value)) { res[key] = value } } } return res }