From 66869ce00ba18439307bf638ff8922448c4dc7a9 Mon Sep 17 00:00:00 2001 From: ITOH Date: Sun, 2 Apr 2023 18:21:48 +0200 Subject: [PATCH] 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. --- packages/utils/src/files.ts | 38 ------------------------------------- packages/utils/src/index.ts | 1 - 2 files changed, 39 deletions(-) delete mode 100644 packages/utils/src/files.ts diff --git a/packages/utils/src/files.ts b/packages/utils/src/files.ts deleted file mode 100644 index 6c6ffe5a9..000000000 --- a/packages/utils/src/files.ts +++ /dev/null @@ -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 - if (typeof file.name !== 'string') { - return false - } - - switch (typeof file.blob) { - case 'string': { - const match = file.blob.match(/^data:(?[a-zA-Z0-9/]*);base64,(?.*)$/) - 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 - } -} diff --git a/packages/utils/src/index.ts b/packages/utils/src/index.ts index 2aead17fc..0c8bc9d02 100644 --- a/packages/utils/src/index.ts +++ b/packages/utils/src/index.ts @@ -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'