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:
ITOH
2023-04-02 16:21:48 +00:00
committed by GitHub
parent 1cb1b09460
commit 66869ce00b
2 changed files with 0 additions and 39 deletions
-38
View File
@@ -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
}
}
-1
View File
@@ -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'