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.
- package/index.js +49 -2
- package/package.json +121 -119
- 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([
|
|
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
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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
|
-
|
|
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
|
|