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

    v12.4.2...v13.0.0