Skip to content

Commit

Permalink
Add support for ac3 and voc formats (#201)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yanis Benson authored and sindresorhus committed Apr 20, 2019
1 parent aacd31a commit 7038abc
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 3 deletions.
Binary file added fixture/fixture.ac3
Binary file not shown.
Binary file added fixture/fixture.voc
Binary file not shown.
4 changes: 3 additions & 1 deletion index.d.ts
Expand Up @@ -97,7 +97,9 @@ declare namespace fileType {
| 'pcap'
| 'dsf'
| 'lnk'
| 'alias';
| 'alias'
| 'voc'
| 'ac3';

interface FileTypeResult {
/**
Expand Down
14 changes: 14 additions & 0 deletions index.js
Expand Up @@ -933,6 +933,20 @@ const fileType = input => {
mime: 'application/x.apple.alias' // Invented by us
};
}

if (checkString('Creative Voice File')) {
return {
ext: 'voc',
mime: 'audio/x-voc'
};
}

if (check([0x0B, 0x77])) {
return {
ext: 'ac3',
mime: 'audio/vnd.dolby.dd-raw'
};
}
};

module.exports = fileType;
Expand Down
4 changes: 3 additions & 1 deletion package.json
Expand Up @@ -122,7 +122,9 @@
"pcap",
"dsf",
"lnk",
"alias"
"alias",
"voc",
"ac3"
],
"devDependencies": {
"@types/node": "^11.12.2",
Expand Down
2 changes: 2 additions & 0 deletions readme.md
Expand Up @@ -219,6 +219,8 @@ Type: [`stream.Readable`](https://nodejs.org/api/stream.html#stream_class_stream
- [`dsf`](https://dsd-guide.com/sites/default/files/white-papers/DSFFileFormatSpec_E.pdf) - Sony DSD Stream File (DSF)
- [`lnk`](https://en.wikipedia.org/wiki/Shortcut_%28computing%29#Microsoft_Windows) - Microsoft Windows file shortcut
- [`alias`](https://en.wikipedia.org/wiki/Alias_%28Mac_OS%29) - macOS Alias file
- [`voc`](https://wiki.multimedia.cx/index.php/Creative_Voice) - Creative Voice File
- [`ac3`](https://www.atsc.org/standard/a522012-digital-audio-compression-ac-3-e-ac-3-standard-12172012/) - ATSC A/52 Audio File

*SVG isn't included as it requires the whole file to be read, but you can get it [here](https://github.com/sindresorhus/is-svg).*

Expand Down
4 changes: 3 additions & 1 deletion test.js
Expand Up @@ -106,7 +106,9 @@ const types = [
'pcap',
'dsf',
'lnk',
'alias'
'alias',
'voc',
'ac3'
];

// Define an entry here only if the fixture has a different
Expand Down

0 comments on commit 7038abc

Please sign in to comment.