refactor: switch posts to barrel export

This commit is contained in:
James Xylight committed 2025-09-07 10:20:04 -07:00
1 parent 0281e6f56a
commit bb30a86dc4
47 files changed
+424 -528

No files matched your search

+20 -12
View File
@@ -92,18 +92,6 @@ export function moveItem<T>(
return newArray
}
type Maybe<T> = T | undefined | void | null
export const trycatch = <T>(func: () => T): Maybe<T> => {
try {
return func()
} catch (err) {
toast({
content: errorMessage(err as string),
type: 'error',
})
}
}
export const removeItem = <T>(array: T[], predicate: (item: T) => boolean) => {
array.splice(array.findIndex(predicate), 1)
}
@@ -206,3 +194,23 @@ export class ReactiveState<T> {
this.value = initialValue as NonNullable<T>
}
}
export const isImage = (url: string | undefined) => {
try {
if (!url) return false
return /\.(jpeg|jpg|gif|png|svg|bmp|webp|avif)/i.test(url)
} catch {
return false
}
}
export const isVideo = (url: string | undefined) => {
try {
if (!url) return false
return /\.(mp4|mov|webm|mkv|avi)/i.test(url)
} catch {
return false
}
}