mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-14 01:37:26 +00:00
Jake’s thoroughness is doing my head in :P
This commit is contained in:
@@ -26,7 +26,7 @@ export const decodersPromise: Promise<Decoder[]> = Promise.all(
|
|||||||
// values here.
|
// values here.
|
||||||
).then(list => list.filter(item => !!item)) as any as Promise<Decoder[]>;
|
).then(list => list.filter(item => !!item)) as any as Promise<Decoder[]>;
|
||||||
|
|
||||||
export async function findDecodersByMimeType(mimeType: string): Promise<Decoder[]> {
|
async function findDecodersByMimeType(mimeType: string): Promise<Decoder[]> {
|
||||||
const decoders = await decodersPromise;
|
const decoders = await decodersPromise;
|
||||||
return decoders.filter(decoder => decoder.canHandleMimeType(mimeType));
|
return decoders.filter(decoder => decoder.canHandleMimeType(mimeType));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ export async function sniffMimeType(blob: Blob): Promise<string> {
|
|||||||
Array.from(new Uint8Array(firstChunk))
|
Array.from(new Uint8Array(firstChunk))
|
||||||
.map(v => String.fromCodePoint(v))
|
.map(v => String.fromCodePoint(v))
|
||||||
.join('');
|
.join('');
|
||||||
for (const [detector, mimeType] of magicNumberToMimeType.entries()) {
|
for (const [detector, mimeType] of magicNumberToMimeType) {
|
||||||
if (detector.test(firstChunkString)) {
|
if (detector.test(firstChunkString)) {
|
||||||
return mimeType;
|
return mimeType;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user