Skip to content

Commit

Permalink
feat: add zstd compression
Browse files Browse the repository at this point in the history
  • Loading branch information
Rdataflow committed Jan 8, 2025
1 parent adf3998 commit 06dbf4f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/compression/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,11 @@ addDecoder(34887, () => import('./lerc.js')
})
.then((m) => m.default),
);
addDecoder(50000, () => import('./zstd.js')
.then(async (m) => {
await m.zstd.init();
return m;
})
.then((m) => m.default),
);
addDecoder(50001, () => import('./webimage.js').then((m) => m.default));
10 changes: 10 additions & 0 deletions src/compression/zstd.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { ZSTDDecoder } from 'zstddec';
import BaseDecoder from './basedecoder.js';

export const zstd = new ZSTDDecoder();

export default class ZstdDecoder extends BaseDecoder {
decodeBlock(buffer) {
return zstd.decode(new Uint8Array(buffer)).buffer;
}
}

0 comments on commit 06dbf4f

Please sign in to comment.