Skip to content

Commit

Permalink
Switch to async, update file-type, add zst, require Node.js 16
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR committed Jun 5, 2023
1 parent 1bd7e6b commit e20627a
Show file tree
Hide file tree
Showing 8 changed files with 243 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node: [14, 16, 18, 20]
node: [16, 18, 20]
os: [ubuntu-latest, windows-latest]

steps:
Expand Down
14 changes: 8 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fileType from 'file-type';
import {fileTypeFromBuffer} from 'file-type';

const exts = new Set([
const extensions = new Set([
'7z',
'bz2',
'gz',
Expand All @@ -9,10 +9,12 @@ const exts = new Set([
'zip',
'xz',
'gz',
'zst',
]);

// eslint-disable-next-line import/no-anonymous-default-export
export default input => {
const type = fileType(input);
return exts.has(type && type.ext) ? type : null;
const archiveType = async input => {
const type = await fileTypeFromBuffer(input);
return extensions.has(type?.ext) ? type : null;
};

export default archiveType;
Loading

0 comments on commit e20627a

Please sign in to comment.