mirror of
https://github.com/Nezumi-2711/onedrive-vercel-index.git
synced 2026-09-22 13:38:45 +00:00
refactor new file download functions to new file
This commit is contained in:
@@ -83,15 +83,15 @@ const extensions = {
|
||||
* @param key The index key
|
||||
* @returns Whether or not the key exists inside the object
|
||||
*/
|
||||
export const hasKey = <O>(obj: O, key: PropertyKey): key is keyof O => {
|
||||
export function hasKey<O>(obj: O, key: PropertyKey): key is keyof O {
|
||||
return key in obj
|
||||
}
|
||||
|
||||
export const getExtension = (fileName: string) => {
|
||||
export function getExtension(fileName: string): string {
|
||||
return fileName.slice(((fileName.lastIndexOf('.') - 1) >>> 0) + 2).toLowerCase()
|
||||
}
|
||||
|
||||
export const getFileIcon = (fileName: string) => {
|
||||
export function getFileIcon(fileName: string): [IconPrefix, IconName] {
|
||||
const extension = getExtension(fileName)
|
||||
return hasKey(extensions, extension) ? extensions[extension] : icons.file
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user