Uint8Array migration

This commit is contained in:
Fedor Indutny
2021-09-23 17:49:05 -07:00
committed by GitHub
parent daf75190b8
commit 4ef0bf96cc
137 changed files with 2202 additions and 3170 deletions

View File

@@ -16,13 +16,10 @@ import {
*
* [0]: https://mimesniff.spec.whatwg.org/#matching-an-image-type-pattern
*/
export function sniffImageMimeType(
bytes: ArrayBuffer | Uint8Array
): undefined | MIMEType {
const asTypedArray = new Uint8Array(bytes);
export function sniffImageMimeType(bytes: Uint8Array): undefined | MIMEType {
for (let i = 0; i < TYPES.length; i += 1) {
const type = TYPES[i];
if (matchesType(asTypedArray, type)) {
if (matchesType(bytes, type)) {
return type.mimeType;
}
}