mirror of
https://github.com/discordeno/discordeno.git
synced 2026-09-17 08:47:22 +00:00
refactor(utils)!: remove unused files utility (#2945)
Since we have changed how files get send to the rest proxy, we do not need this utility anymore.
This commit is contained in:
@@ -1,38 +0,0 @@
|
||||
import type { FileContent } from '@discordeno/types'
|
||||
import { decode } from './base64.js'
|
||||
|
||||
export function findFiles(file: unknown): FileContent[] {
|
||||
if (!file) {
|
||||
return []
|
||||
}
|
||||
|
||||
const files: unknown[] = Array.isArray(file) ? file : [file]
|
||||
return files.filter(coerceToFileContent)
|
||||
}
|
||||
|
||||
export function coerceToFileContent(value: unknown): value is FileContent {
|
||||
if (!value || typeof value !== 'object') {
|
||||
return false
|
||||
}
|
||||
|
||||
const file = value as Record<string, unknown>
|
||||
if (typeof file.name !== 'string') {
|
||||
return false
|
||||
}
|
||||
|
||||
switch (typeof file.blob) {
|
||||
case 'string': {
|
||||
const match = file.blob.match(/^data:(?<mimeType>[a-zA-Z0-9/]*);base64,(?<content>.*)$/)
|
||||
if (match?.groups === undefined) {
|
||||
return false
|
||||
}
|
||||
const { mimeType, content } = match.groups
|
||||
file.blob = new Blob([decode(content)], { type: mimeType })
|
||||
return true
|
||||
}
|
||||
case 'object':
|
||||
return file.blob instanceof Blob
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@ export * from './bucket.js'
|
||||
export * from './casing.js'
|
||||
export * from './Collection.js'
|
||||
export * from './colors.js'
|
||||
export * from './files.js'
|
||||
export * from './hash.js'
|
||||
export * from './images.js'
|
||||
export * from './logger.js'
|
||||
|
||||
Reference in New Issue
Block a user