file-type v13.0.0 Release Notes
Release Date: 2020-01-07 // over 4 years ago-
๐ฅ 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