tav-media
Version:
Cross platform media editing framework
24 lines (23 loc) • 630 B
JavaScript
export const readFile = (file) => new Promise((resolve) => {
const reader = new FileReader();
reader.onload = () => {
resolve(reader.result);
};
reader.onerror = () => {
console.error(reader.error.message);
};
reader.readAsArrayBuffer(file);
});
export const concatUint8Arrays = (arrays) => {
let totalLength = 0;
for (const arr of arrays) {
totalLength += arr.byteLength;
}
const result = new Uint8Array(totalLength);
let offset = 0;
for (const arr of arrays) {
result.set(arr, offset);
offset += arr.byteLength;
}
return result;
};