npm file-type 22.0.0

15 hours ago

Breaking

  • Requires Node.js 22

  • Dropped Node.js stream.Readable support from fileTypeFromStream() and fileTypeStream()

    // Before
    import fs from 'node:fs';
    fileTypeFromStream(fs.createReadStream('file.mp4'));
    
    // After
    import fs from 'node:fs';
    import {Readable} from 'node:stream';
    fileTypeFromStream(Readable.toWeb(fs.createReadStream('file.mp4')));
  • Sub-exports (e.g. file-type/core) have been removed. Import everything from file-type directly.

  • The ReadableStreamWithFileType type has been removed. Use AnyWebReadableByteStreamWithFileType instead.

  • Several MIME types have been corrected or normalized:

    Type Old MIME New MIME
    lz application/x-lzip application/lzip
    lnk application/x.ms.shortcut application/x-ms-shortcut
    Apple Alias application/x.apple.alias application/x-ft-apple.alias
    fbx application/x.autodesk.fbx application/x-ft-fbx
    Draco application/vnd.google.draco application/x-ft-draco

    MIME subtypes prefixed with x-ft- are custom types defined by this package (not IANA-registered).

Improvements

  • Added detection for Apple iWork files: .key (Keynote), .pages (Pages), .numbers (Numbers)

Fixes

  • Fixed LibreOffice OOXML files being incorrectly detected as ZIP when reading from streams

v21.3.4...v22.0.0

Don't miss a new file-type release

NewReleases is sending notifications on new releases.