file-type 6.1.0 → 6.2.0
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 +18 -9
- package/license +4 -16
- package/package.json +108 -110
- package/readme.md +8 -2
package/index.js
CHANGED
|
@@ -17,7 +17,13 @@ module.exports = input => {
|
|
|
17
17
|
}, opts);
|
|
18
18
|
|
|
19
19
|
for (let i = 0; i < header.length; i++) {
|
|
20
|
-
|
|
20
|
+
// If a bitmask is set
|
|
21
|
+
if (opts.mask) {
|
|
22
|
+
// If header doesn't equal `buf` with bits masked off
|
|
23
|
+
if (header[i] !== (opts.mask[i] & buf[i + opts.offset])) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
} else if (header[i] !== buf[i + opts.offset]) {
|
|
21
27
|
return false;
|
|
22
28
|
}
|
|
23
29
|
}
|
|
@@ -302,14 +308,17 @@ module.exports = input => {
|
|
|
302
308
|
};
|
|
303
309
|
}
|
|
304
310
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
311
|
+
// Check for MP3 header at different starting offsets
|
|
312
|
+
for (let start = 0; start < 2 && start < (buf.length - 16); start++) {
|
|
313
|
+
if (
|
|
314
|
+
check([0x49, 0x44, 0x33], {offset: start}) || // ID3 header
|
|
315
|
+
check([0xFF, 0xE2], {offset: start, mask: [0xFF, 0xE2]}) // MPEG 1 or 2 Layer 3 header
|
|
316
|
+
) {
|
|
317
|
+
return {
|
|
318
|
+
ext: 'mp3',
|
|
319
|
+
mime: 'audio/mpeg'
|
|
320
|
+
};
|
|
321
|
+
}
|
|
313
322
|
}
|
|
314
323
|
|
|
315
324
|
if (
|
package/license
CHANGED
|
@@ -1,21 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
MIT License
|
|
2
2
|
|
|
3
3
|
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
|
4
4
|
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
11
6
|
|
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
|
13
|
-
all copies or substantial portions of the Software.
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
14
8
|
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
-
THE SOFTWARE.
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/package.json
CHANGED
|
@@ -1,112 +1,110 @@
|
|
|
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
|
-
"xo": "*"
|
|
111
|
-
}
|
|
2
|
+
"name": "file-type",
|
|
3
|
+
"version": "6.2.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
|
+
"swf",
|
|
76
|
+
"rtf",
|
|
77
|
+
"woff",
|
|
78
|
+
"woff2",
|
|
79
|
+
"eot",
|
|
80
|
+
"ttf",
|
|
81
|
+
"otf",
|
|
82
|
+
"ico",
|
|
83
|
+
"flv",
|
|
84
|
+
"ps",
|
|
85
|
+
"xz",
|
|
86
|
+
"sqlite",
|
|
87
|
+
"xpi",
|
|
88
|
+
"cab",
|
|
89
|
+
"deb",
|
|
90
|
+
"ar",
|
|
91
|
+
"rpm",
|
|
92
|
+
"Z",
|
|
93
|
+
"lz",
|
|
94
|
+
"msi",
|
|
95
|
+
"mxf",
|
|
96
|
+
"mts",
|
|
97
|
+
"wasm",
|
|
98
|
+
"webassembly",
|
|
99
|
+
"blend",
|
|
100
|
+
"bpg",
|
|
101
|
+
"docx",
|
|
102
|
+
"pptx",
|
|
103
|
+
"xlsx"
|
|
104
|
+
],
|
|
105
|
+
"devDependencies": {
|
|
106
|
+
"ava": "*",
|
|
107
|
+
"read-chunk": "^2.0.0",
|
|
108
|
+
"xo": "*"
|
|
109
|
+
}
|
|
112
110
|
}
|
package/readme.md
CHANGED
|
@@ -8,7 +8,7 @@ The file type is detected by checking the [magic number](http://en.wikipedia.org
|
|
|
8
8
|
## Install
|
|
9
9
|
|
|
10
10
|
```
|
|
11
|
-
$ npm install
|
|
11
|
+
$ npm install file-type
|
|
12
12
|
```
|
|
13
13
|
|
|
14
14
|
|
|
@@ -154,6 +154,12 @@ It only needs the first 4100 bytes.
|
|
|
154
154
|
- [file-type-cli](https://github.com/sindresorhus/file-type-cli) - CLI for this module
|
|
155
155
|
|
|
156
156
|
|
|
157
|
+
## Created by
|
|
158
|
+
|
|
159
|
+
- [Sindre Sorhus](https://github.com/sindresorhus)
|
|
160
|
+
- [Mikael Finstad](https://github.com/mifi)
|
|
161
|
+
|
|
162
|
+
|
|
157
163
|
## License
|
|
158
164
|
|
|
159
|
-
MIT
|
|
165
|
+
MIT
|