Breaking
- Require Node.js 10 0b97a85
- Rewrite the API and make it async (#286) 8f981c3
- Why: To be non-blocking, to be able to accept a stream as input, and improved file type detection.
- Migrate:
-const fileType = require('file-type');
+const FileType = require('file-type');
-console.log(fileType(buffer));
+console.log(await FileType.fromBuffer(buffer));
- Browser supports was moved into a sub-module:
- Migrate:
-const fileType = require('file-type');
+const fileType = require('file-type/browser');
Enhancements
- Add
.fromFile()
method to detect the file type of a file (#286) 8f981c3 - Add
.fromStream()
method to detect the file type of a stream (#286) 8f981c3
If you have access to the file, this method is recommended over.fromBuffer()
, as it can better optimize the detection speed. - Add
.fromBlob()
convenience method when used in the browser (#286) 8f981c3 - Add support for
CR3
(#292) 204599a - Stop execution after
FileType.stream()
error (#273) 3840e6a