@tstdl/base 0.93.196 → 0.93.197
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/file/mime-type.js +2 -1
- package/package.json +1 -1
package/file/mime-type.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { fileTypeFromBuffer, fileTypeFromStream } from 'file-type';
|
|
2
1
|
import { match } from 'ts-pattern';
|
|
2
|
+
import { dynamicImport } from '../import.js';
|
|
3
3
|
import { isReadableStream, isUint8Array } from '../utils/type-guards.js';
|
|
4
4
|
import { mimeTypesMap } from './mime-types.js';
|
|
5
5
|
export async function getMimeType(file, fallback) {
|
|
6
|
+
const { fileTypeFromBuffer, fileTypeFromStream } = await dynamicImport('file-type');
|
|
6
7
|
const result = await match(file)
|
|
7
8
|
.when(isUint8Array, async (f) => await fileTypeFromBuffer(f))
|
|
8
9
|
.when((isReadableStream), async (f) => await fileTypeFromStream(f))
|