Files
Desktop/ts/util/arrayBufferToObjectURL.std.ts
Fedor Indutny 44076ece79 Rename files
2025-10-16 23:45:44 -07:00

21 lines
441 B
TypeScript

// Copyright 2018 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import type { MIMEType } from '../types/MIME.std.js';
export const arrayBufferToObjectURL = ({
data,
type,
}: {
data: ArrayBuffer;
type: MIMEType;
}): string => {
if (!(data instanceof ArrayBuffer)) {
throw new TypeError('`data` must be an ArrayBuffer');
}
const blob = new Blob([data], { type });
return URL.createObjectURL(blob);
};