openreplay/frontend/app/player/common/tarball.ts
Andrey Babushkin fd5c0c9747
Add lokalisation (#3092)
* applied eslint

* add locales and lint the project

* removed error boundary

* updated locales

* fix min files

* fix locales
2025-03-06 17:43:15 +01:00

27 lines
732 B
TypeScript

import untar, { TarFile } from 'js-untar';
const unpackTar = (data: Uint8Array): Promise<TarFile[]> => {
const isTar = true;
// tarball ustar starts from 257, 75 73 74 61 72, but this is getting lost here for some reason
// so we rely on try catch
// data[257] === 0x75 &&
// data[258] === 0x73 &&
// data[259] === 0x74 &&
// data[260] === 0x61 &&
// data[261] === 0x72 &&
// data[262] === 0x00;
if (isTar) {
const now = performance.now();
return untar(data.buffer).then((files) => {
console.debug(
'Tar unpack time',
`${Math.floor(performance.now() - now)}ms`,
);
return files;
});
}
return Promise.reject('Not a tarball file');
};
export default unpackTar;