file-type 7.4.0 → 7.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.js +49 -2
  2. package/package.json +121 -119
  3. package/readme.md +6 -1
package/index.js CHANGED
@@ -334,14 +334,14 @@ module.exports = input => {
334
334
  };
335
335
  }
336
336
 
337
- if (check([0x0, 0x0, 0x0, 0x1C, 0x66, 0x74, 0x79, 0x70, 0x33, 0x67, 0x70, 0x34])) {
337
+ if (check([0x66, 0x74, 0x79, 0x70, 0x33, 0x67], {offset: 4})) {
338
338
  return {
339
339
  ext: '3gp',
340
340
  mime: 'video/3gpp'
341
341
  };
342
342
  }
343
343
 
344
- // Check for MP3 header at different starting offsets
344
+ // Check for MPEG header at different starting offsets
345
345
  for (let start = 0; start < 2 && start < (buf.length - 16); start++) {
346
346
  if (
347
347
  check([0x49, 0x44, 0x33], {offset: start}) || // ID3 header
@@ -352,6 +352,15 @@ module.exports = input => {
352
352
  mime: 'audio/mpeg'
353
353
  };
354
354
  }
355
+
356
+ if (
357
+ check([0xFF, 0xE4], {offset: start, mask: [0xFF, 0xE4]}) // MPEG 1 or 2 Layer 2 header
358
+ ) {
359
+ return {
360
+ ext: 'mp2',
361
+ mime: 'audio/mpeg'
362
+ };
363
+ }
355
364
  }
356
365
 
357
366
  if (
@@ -544,6 +553,13 @@ module.exports = input => {
544
553
  };
545
554
  }
546
555
 
556
+ if (check([0x00, 0x00, 0x02, 0x00])) {
557
+ return {
558
+ ext: 'cur',
559
+ mime: 'image/x-icon'
560
+ };
561
+ }
562
+
547
563
  if (check([0x46, 0x4C, 0x56, 0x01])) {
548
564
  return {
549
565
  ext: 'flv',
@@ -723,5 +739,36 @@ module.exports = input => {
723
739
  };
724
740
  }
725
741
 
742
+ // File Type Box (https://en.wikipedia.org/wiki/ISO_base_media_file_format)
743
+ if (check([0x66, 0x74, 0x79, 0x70], {offset: 4})) {
744
+ if (check([0x6D, 0x69, 0x66, 0x31], {offset: 8})) {
745
+ return {
746
+ ext: 'heic',
747
+ mime: 'image/heif'
748
+ };
749
+ }
750
+
751
+ if (check([0x6D, 0x73, 0x66, 0x31], {offset: 8})) {
752
+ return {
753
+ ext: 'heic',
754
+ mime: 'image/heif-sequence'
755
+ };
756
+ }
757
+
758
+ if (check([0x68, 0x65, 0x69, 0x63], {offset: 8}) || check([0x68, 0x65, 0x69, 0x78], {offset: 8})) {
759
+ return {
760
+ ext: 'heic',
761
+ mime: 'image/heic'
762
+ };
763
+ }
764
+
765
+ if (check([0x68, 0x65, 0x76, 0x63], {offset: 8}) || check([0x68, 0x65, 0x76, 0x78], {offset: 8})) {
766
+ return {
767
+ ext: 'heic',
768
+ mime: 'image/heic-sequence'
769
+ };
770
+ }
771
+ }
772
+
726
773
  return null;
727
774
  };
package/package.json CHANGED
@@ -1,121 +1,123 @@
1
1
  {
2
- "name": "file-type",
3
- "version": "7.4.0",
4
- "description": "Detect the file type of a Buffer/Uint8Array",
5
- "license": "MIT",
6
- "repository": "sindresorhus/file-type",
7
- "author": {
8
- "name": "Sindre Sorhus",
9
- "email": "sindresorhus@gmail.com",
10
- "url": "sindresorhus.com"
11
- },
12
- "engines": {
13
- "node": ">=4"
14
- },
15
- "scripts": {
16
- "test": "xo && ava"
17
- },
18
- "files": [
19
- "index.js"
20
- ],
21
- "keywords": [
22
- "mime",
23
- "file",
24
- "type",
25
- "archive",
26
- "image",
27
- "img",
28
- "pic",
29
- "picture",
30
- "flash",
31
- "photo",
32
- "video",
33
- "detect",
34
- "check",
35
- "is",
36
- "exif",
37
- "exe",
38
- "binary",
39
- "buffer",
40
- "uint8array",
41
- "jpg",
42
- "png",
43
- "gif",
44
- "webp",
45
- "flif",
46
- "cr2",
47
- "tif",
48
- "bmp",
49
- "jxr",
50
- "psd",
51
- "zip",
52
- "tar",
53
- "rar",
54
- "gz",
55
- "bz2",
56
- "7z",
57
- "dmg",
58
- "mp4",
59
- "m4v",
60
- "mid",
61
- "mkv",
62
- "webm",
63
- "mov",
64
- "avi",
65
- "mpg",
66
- "mp3",
67
- "m4a",
68
- "ogg",
69
- "opus",
70
- "flac",
71
- "wav",
72
- "amr",
73
- "pdf",
74
- "epub",
75
- "mobi",
76
- "swf",
77
- "rtf",
78
- "woff",
79
- "woff2",
80
- "eot",
81
- "ttf",
82
- "otf",
83
- "ico",
84
- "flv",
85
- "ps",
86
- "xz",
87
- "sqlite",
88
- "xpi",
89
- "cab",
90
- "deb",
91
- "ar",
92
- "rpm",
93
- "Z",
94
- "lz",
95
- "msi",
96
- "mxf",
97
- "mts",
98
- "wasm",
99
- "webassembly",
100
- "blend",
101
- "bpg",
102
- "docx",
103
- "pptx",
104
- "xlsx",
105
- "3gp",
106
- "jp2",
107
- "jpm",
108
- "jpx",
109
- "mj2",
110
- "aif",
111
- "odt",
112
- "ods",
113
- "odp",
114
- "xml"
115
- ],
116
- "devDependencies": {
117
- "ava": "*",
118
- "read-chunk": "^2.0.0",
119
- "xo": "*"
120
- }
2
+ "name": "file-type",
3
+ "version": "7.7.1",
4
+ "description": "Detect the file type of a Buffer/Uint8Array",
5
+ "license": "MIT",
6
+ "repository": "sindresorhus/file-type",
7
+ "author": {
8
+ "name": "Sindre Sorhus",
9
+ "email": "sindresorhus@gmail.com",
10
+ "url": "sindresorhus.com"
11
+ },
12
+ "engines": {
13
+ "node": ">=4"
14
+ },
15
+ "scripts": {
16
+ "test": "xo && ava"
17
+ },
18
+ "files": [
19
+ "index.js"
20
+ ],
21
+ "keywords": [
22
+ "mime",
23
+ "file",
24
+ "type",
25
+ "archive",
26
+ "image",
27
+ "img",
28
+ "pic",
29
+ "picture",
30
+ "flash",
31
+ "photo",
32
+ "video",
33
+ "detect",
34
+ "check",
35
+ "is",
36
+ "exif",
37
+ "exe",
38
+ "binary",
39
+ "buffer",
40
+ "uint8array",
41
+ "jpg",
42
+ "png",
43
+ "gif",
44
+ "webp",
45
+ "flif",
46
+ "cr2",
47
+ "tif",
48
+ "bmp",
49
+ "jxr",
50
+ "psd",
51
+ "zip",
52
+ "tar",
53
+ "rar",
54
+ "gz",
55
+ "bz2",
56
+ "7z",
57
+ "dmg",
58
+ "mp4",
59
+ "m4v",
60
+ "mid",
61
+ "mkv",
62
+ "webm",
63
+ "mov",
64
+ "avi",
65
+ "mpg",
66
+ "mp2",
67
+ "mp3",
68
+ "m4a",
69
+ "ogg",
70
+ "opus",
71
+ "flac",
72
+ "wav",
73
+ "amr",
74
+ "pdf",
75
+ "epub",
76
+ "mobi",
77
+ "swf",
78
+ "rtf",
79
+ "woff",
80
+ "woff2",
81
+ "eot",
82
+ "ttf",
83
+ "otf",
84
+ "ico",
85
+ "flv",
86
+ "ps",
87
+ "xz",
88
+ "sqlite",
89
+ "xpi",
90
+ "cab",
91
+ "deb",
92
+ "ar",
93
+ "rpm",
94
+ "Z",
95
+ "lz",
96
+ "msi",
97
+ "mxf",
98
+ "mts",
99
+ "wasm",
100
+ "webassembly",
101
+ "blend",
102
+ "bpg",
103
+ "docx",
104
+ "pptx",
105
+ "xlsx",
106
+ "3gp",
107
+ "jp2",
108
+ "jpm",
109
+ "jpx",
110
+ "mj2",
111
+ "aif",
112
+ "odt",
113
+ "ods",
114
+ "odp",
115
+ "xml",
116
+ "heic"
117
+ ],
118
+ "devDependencies": {
119
+ "ava": "*",
120
+ "read-chunk": "^2.0.0",
121
+ "xo": "*"
122
+ }
121
123
  }
package/readme.md CHANGED
@@ -11,7 +11,9 @@ The file type is detected by checking the [magic number](http://en.wikipedia.org
11
11
  $ npm install file-type
12
12
  ```
13
13
 
14
- *Show your support for this module by buying this excellent [Node.js course](https://LearnNode.com/friend/AWESOME).*
14
+ <a href="https://www.patreon.com/sindresorhus">
15
+ <img src="https://c5.patreon.com/external/logo/become_a_patron_button@2x.png" width="160">
16
+ </a>
15
17
 
16
18
 
17
19
  ## Usage
@@ -105,6 +107,7 @@ It only needs the first 4100 bytes.
105
107
  - [`avi`](https://en.wikipedia.org/wiki/Audio_Video_Interleave)
106
108
  - [`wmv`](https://en.wikipedia.org/wiki/Windows_Media_Video)
107
109
  - [`mpg`](https://en.wikipedia.org/wiki/MPEG-1)
110
+ - [`mp2`](https://en.wikipedia.org/wiki/MPEG-1_Audio_Layer_II)
108
111
  - [`mp3`](https://en.wikipedia.org/wiki/MP3)
109
112
  - [`m4a`](https://en.wikipedia.org/wiki/MPEG-4_Part_14#.MP4_versus_.M4A)
110
113
  - [`ogg`](https://en.wikipedia.org/wiki/Ogg)
@@ -156,6 +159,8 @@ It only needs the first 4100 bytes.
156
159
  - [`ods`](https://en.wikipedia.org/wiki/OpenDocument) - OpenDocument for spreadsheets
157
160
  - [`odp`](https://en.wikipedia.org/wiki/OpenDocument) - OpenDocument for presentations
158
161
  - [`xml`](https://en.wikipedia.org/wiki/XML)
162
+ - [`heic`](http://nokiatech.github.io/heif/technical.html)
163
+ - [`cur`](https://en.wikipedia.org/wiki/ICO_(file_format))
159
164
 
160
165
  *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).*
161
166