Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Zstandard compressed file #439

Merged
merged 2 commits into from
Mar 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions core.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ declare namespace core {
| 'asar'
| 'stl'
| 'chm'
| '3mf';
| '3mf'
| 'zst';

type MimeType =
| 'image/jpeg'
Expand Down Expand Up @@ -268,7 +269,8 @@ declare namespace core {
| 'application/x-asar'
| 'model/stl'
| 'application/vnd.ms-htmlhelp'
| 'model/3mf';
| 'model/3mf'
| 'application/zstd';

interface FileTypeResult {
/**
Expand Down Expand Up @@ -376,4 +378,3 @@ declare namespace core {
}

export = core;

7 changes: 7 additions & 0 deletions core.js
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,13 @@ async function _fromTokenizer(tokenizer) {
};
}

if (check([0x28, 0xB5, 0x2F, 0xFD])) {
return {
ext: 'zst',
mime: 'application/zstd'
};
}

// -- 5-byte signatures --

if (check([0x4F, 0x54, 0x54, 0x4F, 0x00])) {
Expand Down
Binary file added fixture/fixture.tar.zst
Binary file not shown.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@
"asar",
"stl",
"chm",
"3mf"
"3mf",
"zst"
],
"devDependencies": {
"@types/node": "^13.1.4",
Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ Returns a set of supported MIME types.
- [`rar`](https://en.wikipedia.org/wiki/RAR_(file_format)) - Archive file
- [`gz`](https://en.wikipedia.org/wiki/Gzip) - Archive file
- [`bz2`](https://en.wikipedia.org/wiki/Bzip2) - Archive file
- [`zst`](https://en.wikipedia.org/wiki/Zstandard) - Archive file
- [`7z`](https://en.wikipedia.org/wiki/7z) - 7-Zip archive
- [`dmg`](https://en.wikipedia.org/wiki/Apple_Disk_Image) - Apple Disk Image
- [`mp4`](https://en.wikipedia.org/wiki/MPEG-4_Part_14#Filename_extensions) - MPEG-4 Part 14 video file
Expand Down
6 changes: 4 additions & 2 deletions supported.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ module.exports = {
'asar',
'stl',
'chm',
'3mf'
'3mf',
'zst'
],
mimeTypes: [
'image/jpeg',
Expand Down Expand Up @@ -266,6 +267,7 @@ module.exports = {
'application/x-asar',
'model/stl',
'application/vnd.ms-htmlhelp',
'model/3mf'
'model/3mf',
'application/zstd'
]
};
3 changes: 3 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ const names = {
Z: [
'fixture.tar'
],
zst: [
'fixture.tar'
],
mkv: [
'fixture',
'fixture2'
Expand Down