迁移 orm 依赖到 drizzle
This commit is contained in:
@@ -6,12 +6,11 @@ export function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs))
|
||||
}
|
||||
|
||||
// 数据验证函数
|
||||
export const validateNumber = (value: unknown): number => {
|
||||
if (typeof value === 'number') return value
|
||||
if (typeof value === 'string') {
|
||||
const num = parseInt(value)
|
||||
return isNaN(num) ? 0 : num
|
||||
}
|
||||
return 0
|
||||
// 取数组第一个元素,支持映射
|
||||
export function first<T>(array: T[]): T | undefined
|
||||
export function first<T, I>(array: T[], select: (item: T) => I): I | undefined
|
||||
|
||||
export function first<T, I>(array: T[], select?: (item: T) => I) {
|
||||
const item = array.length > 0 ? array[0] : undefined
|
||||
return select && item ? select(item) : item
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user