{"_id":"@alexssmusica/file-type","_rev":"2-feffa97c29eeb2c6db29e0baafc509d7","name":"@alexssmusica/file-type","dist-tags":{"latest":"18.5.3"},"versions":{"18.5.1":{"name":"@alexssmusica/file-type","version":"18.5.1","description":"Detect the file type of a Buffer/Uint8Array/ArrayBuffer","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/file-type.git"},"funding":"https://github.com/sindresorhus/file-type?sponsor=1","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"exports":{".":{"node":"./index.js","default":"./browser.js"},"./core":"./core.js"},"engines":{"node":">=14.16"},"scripts":{"test":"xo && ava && tsd"},"keywords":["mime","file","type","magic","archive","image","img","pic","picture","flash","photo","video","detect","check","is","exif","elf","exe","binary","buffer","uint8array","jpg","png","apng","gif","webp","flif","xcf","cr2","cr3","orf","arw","dng","nef","rw2","raf","tif","bmp","icns","jxr","psd","indd","zip","tar","rar","gz","bz2","7z","dmg","mp4","mid","mkv","webm","mov","avi","mpg","mp2","mp3","m4a","ogg","opus","flac","wav","amr","pdf","epub","mobi","swf","rtf","woff","woff2","eot","ttf","otf","ico","flv","ps","xz","sqlite","xpi","cab","deb","ar","rpm","Z","lz","cfb","mxf","mts","wasm","webassembly","blend","bpg","docx","pptx","xlsx","3gp","j2c","jp2","jpm","jpx","mj2","aif","odt","ods","odp","xml","heic","ics","glb","pcap","dsf","lnk","alias","voc","ac3","3g2","m4b","m4p","m4v","f4a","f4b","f4p","f4v","mie","qcp","asf","ogv","ogm","oga","spx","ogx","ape","wv","cur","nes","crx","ktx","dcm","mpc","arrow","shp","aac","mp1","it","s3m","xm","ai","skp","avif","eps","lzh","pgp","asar","stl","chm","3mf","zst","jxl","vcf","jls","pst","dwg","parquet","class","arj","cpio","ace","avro","icc"],"dependencies":{"readable-web-to-node-stream":"^3.0.2","strtok3":"^7.0.0","token-types":"^5.0.1"},"devDependencies":{"@tokenizer/token":"^0.3.0","@types/node":"^20.1.2","ava":"^5.2.0","commonmark":"^0.30.0","noop-stream":"^1.0.0","tsd":"^0.28.1","xo":"^0.54.2"},"xo":{"envs":["node","browser"],"rules":{"no-inner-declarations":"warn","no-await-in-loop":"warn","no-bitwise":"off","@typescript-eslint/no-unsafe-assignment":"off","unicorn/text-encoding-identifier-case":"off","unicorn/switch-case-braces":"off","unicorn/prefer-top-level-await":"off"}},"ava":{"serial":true},"gitHead":"b6659aa08f1357536b94d3648f16d2f9a395f69c","bugs":{"url":"https://github.com/sindresorhus/file-type/issues"},"homepage":"https://github.com/sindresorhus/file-type#readme","_id":"@alexssmusica/file-type@18.5.1","_nodeVersion":"14.19.3","_npmVersion":"6.14.17","dist":{"integrity":"sha512-s2AUIg8uhUWRZdUYj8m9YfEDONCpIneTHp58HnB61+p54H4AzwAaWYYfx20wovCreb8qkhN/6OV5UExtd6ZpKQ==","shasum":"31a589bfd675281fea072d365d4146be7eecb7d2","tarball":"https://registry.npmjs.org/@alexssmusica/file-type/-/file-type-18.5.1.tgz","fileCount":11,"unpackedSize":84696,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDsdB3eNk9w5f59sJVzGXHQlePXIVk7BaqDnscsQkmekgIgJL71zAiinujC+2F2FduPy+BcQByYH3rabCoJNPOBRfE="}]},"_npmUser":{"name":"alexssmusica","email":"alexssmusica@gmail.com"},"directories":{},"maintainers":[{"name":"alexssmusica","email":"alexssmusica@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/file-type_18.5.1_1690208842228_0.7018706767167977"},"_hasShrinkwrap":false},"18.5.2":{"name":"@alexssmusica/file-type","version":"18.5.2","description":"Detect the file type of a Buffer/Uint8Array/ArrayBuffer","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/file-type.git"},"funding":"https://github.com/sindresorhus/file-type?sponsor=1","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"exports":{".":{"node":"./index.js","default":"./browser.js"},"./core":"./core.js"},"engines":{"node":">=14.16"},"scripts":{"test":"xo && ava && tsd"},"keywords":["mime","file","type","magic","archive","image","img","pic","picture","flash","photo","video","detect","check","is","exif","elf","exe","binary","buffer","uint8array","jpg","png","apng","gif","webp","flif","xcf","cr2","cr3","orf","arw","dng","nef","rw2","raf","tif","bmp","icns","jxr","psd","indd","zip","tar","rar","gz","bz2","7z","dmg","mp4","mid","mkv","webm","mov","avi","mpg","mp2","mp3","m4a","ogg","opus","flac","wav","amr","pdf","epub","mobi","swf","rtf","woff","woff2","eot","ttf","otf","ico","flv","ps","xz","sqlite","xpi","cab","deb","ar","rpm","Z","lz","cfb","mxf","mts","wasm","webassembly","blend","bpg","docx","pptx","xlsx","3gp","j2c","jp2","jpm","jpx","mj2","aif","odt","ods","odp","xml","heic","ics","glb","pcap","dsf","lnk","alias","voc","ac3","3g2","m4b","m4p","m4v","f4a","f4b","f4p","f4v","mie","qcp","asf","ogv","ogm","oga","spx","ogx","ape","wv","cur","nes","crx","ktx","dcm","mpc","arrow","shp","aac","mp1","it","s3m","xm","ai","skp","avif","eps","lzh","pgp","asar","stl","chm","3mf","zst","jxl","vcf","jls","pst","dwg","parquet","class","arj","cpio","ace","avro","icc"],"dependencies":{"readable-web-to-node-stream":"^3.0.2","@alexssmusica/strtok3":"^7.0.1","token-types":"^5.0.1"},"devDependencies":{"@tokenizer/token":"^0.3.0","@types/node":"^20.1.2","ava":"^5.2.0","commonmark":"^0.30.0","noop-stream":"^1.0.0","tsd":"^0.28.1","xo":"^0.54.2"},"xo":{"envs":["node","browser"],"rules":{"no-inner-declarations":"warn","no-await-in-loop":"warn","no-bitwise":"off","@typescript-eslint/no-unsafe-assignment":"off","unicorn/text-encoding-identifier-case":"off","unicorn/switch-case-braces":"off","unicorn/prefer-top-level-await":"off"}},"ava":{"serial":true},"gitHead":"74c28ec414d10199db377e9e5c58253b47059f0e","bugs":{"url":"https://github.com/sindresorhus/file-type/issues"},"homepage":"https://github.com/sindresorhus/file-type#readme","_id":"@alexssmusica/file-type@18.5.2","_nodeVersion":"14.19.3","_npmVersion":"6.14.17","dist":{"integrity":"sha512-1jDjE5qSyBo9sGhoc5KvXPDuCzhwNR2RUY83q+pnpMaL7zx15mLiQm6JCUE8Z8VHJcUp5WHGWDInUt4Uzjwxvg==","shasum":"ffe8bf034558916bf61d7246fcee9ea9d0ab8513","tarball":"https://registry.npmjs.org/@alexssmusica/file-type/-/file-type-18.5.2.tgz","fileCount":11,"unpackedSize":84738,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDLg6TZkU6bA52DVTiQH6pFfsI3skDwgI8ap0UqF0d7qwIhAL86SGcxQ+O/Yossb+PILHRjWQgFFv/Ii0OiHYDW6y1U"}]},"_npmUser":{"name":"alexssmusica","email":"alexssmusica@gmail.com"},"directories":{},"maintainers":[{"name":"alexssmusica","email":"alexssmusica@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/file-type_18.5.2_1690210962842_0.2783364485340989"},"_hasShrinkwrap":false},"18.5.3":{"name":"@alexssmusica/file-type","version":"18.5.3","description":"Detect the file type of a Buffer/Uint8Array/ArrayBuffer","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/file-type.git"},"funding":"https://github.com/sindresorhus/file-type?sponsor=1","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"exports":{".":{"node":"./index.js","default":"./browser.js"},"./core":"./core.js"},"engines":{"node":">=14.16"},"scripts":{"test":"xo && ava && tsd"},"keywords":["mime","file","type","magic","archive","image","img","pic","picture","flash","photo","video","detect","check","is","exif","elf","exe","binary","buffer","uint8array","jpg","png","apng","gif","webp","flif","xcf","cr2","cr3","orf","arw","dng","nef","rw2","raf","tif","bmp","icns","jxr","psd","indd","zip","tar","rar","gz","bz2","7z","dmg","mp4","mid","mkv","webm","mov","avi","mpg","mp2","mp3","m4a","ogg","opus","flac","wav","amr","pdf","epub","mobi","swf","rtf","woff","woff2","eot","ttf","otf","ico","flv","ps","xz","sqlite","xpi","cab","deb","ar","rpm","Z","lz","cfb","mxf","mts","wasm","webassembly","blend","bpg","docx","pptx","xlsx","3gp","j2c","jp2","jpm","jpx","mj2","aif","odt","ods","odp","xml","heic","ics","glb","pcap","dsf","lnk","alias","voc","ac3","3g2","m4b","m4p","m4v","f4a","f4b","f4p","f4v","mie","qcp","asf","ogv","ogm","oga","spx","ogx","ape","wv","cur","nes","crx","ktx","dcm","mpc","arrow","shp","aac","mp1","it","s3m","xm","ai","skp","avif","eps","lzh","pgp","asar","stl","chm","3mf","zst","jxl","vcf","jls","pst","dwg","parquet","class","arj","cpio","ace","avro","icc"],"dependencies":{"readable-web-to-node-stream":"^3.0.2","@alexssmusica/strtok3":"^7.0.1","token-types":"^5.0.1"},"devDependencies":{"@tokenizer/token":"^0.3.0","@types/node":"^20.1.2","ava":"^5.2.0","commonmark":"^0.30.0","noop-stream":"^1.0.0","tsd":"^0.28.1","xo":"^0.54.2"},"xo":{"envs":["node","browser"],"rules":{"no-inner-declarations":"warn","no-await-in-loop":"warn","no-bitwise":"off","@typescript-eslint/no-unsafe-assignment":"off","unicorn/text-encoding-identifier-case":"off","unicorn/switch-case-braces":"off","unicorn/prefer-top-level-await":"off"}},"ava":{"serial":true},"gitHead":"7a6c061af58df0c6bc7c3cc4cfce5149f3ce268b","bugs":{"url":"https://github.com/sindresorhus/file-type/issues"},"homepage":"https://github.com/sindresorhus/file-type#readme","_id":"@alexssmusica/file-type@18.5.3","_nodeVersion":"14.19.3","_npmVersion":"6.14.17","dist":{"integrity":"sha512-WOuz6P0mZLOS5RLiGtD/yv9CZWGp6DkMLkXfzBKvxoMGMElzd0ksbfeILugwqkg8MsYhTK5lq7qTs+23jGpkVw==","shasum":"3d19d221c04c06b70b92466d3aa2dfb0c0e55705","tarball":"https://registry.npmjs.org/@alexssmusica/file-type/-/file-type-18.5.3.tgz","fileCount":11,"unpackedSize":84805,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGzPT5RU51Sxdx3WjvVV63b0BgNpMN2VeuTTQMICwZPVAiEAweQpNLvFEVdqCvLkfwumt4RPCfm1+6Rn43lZkrZ2LCY="}]},"_npmUser":{"name":"alexssmusica","email":"alexssmusica@gmail.com"},"directories":{},"maintainers":[{"name":"alexssmusica","email":"alexssmusica@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/file-type_18.5.3_1690211496507_0.03149746543794807"},"_hasShrinkwrap":false}},"time":{"created":"2023-07-24T14:27:22.131Z","18.5.1":"2023-07-24T14:27:22.432Z","modified":"2023-07-24T15:11:36.910Z","18.5.2":"2023-07-24T15:02:43.131Z","18.5.3":"2023-07-24T15:11:36.749Z"},"maintainers":[{"name":"alexssmusica","email":"alexssmusica@gmail.com"}],"description":"Detect the file type of a Buffer/Uint8Array/ArrayBuffer","homepage":"https://github.com/sindresorhus/file-type#readme","keywords":["mime","file","type","magic","archive","image","img","pic","picture","flash","photo","video","detect","check","is","exif","elf","exe","binary","buffer","uint8array","jpg","png","apng","gif","webp","flif","xcf","cr2","cr3","orf","arw","dng","nef","rw2","raf","tif","bmp","icns","jxr","psd","indd","zip","tar","rar","gz","bz2","7z","dmg","mp4","mid","mkv","webm","mov","avi","mpg","mp2","mp3","m4a","ogg","opus","flac","wav","amr","pdf","epub","mobi","swf","rtf","woff","woff2","eot","ttf","otf","ico","flv","ps","xz","sqlite","xpi","cab","deb","ar","rpm","Z","lz","cfb","mxf","mts","wasm","webassembly","blend","bpg","docx","pptx","xlsx","3gp","j2c","jp2","jpm","jpx","mj2","aif","odt","ods","odp","xml","heic","ics","glb","pcap","dsf","lnk","alias","voc","ac3","3g2","m4b","m4p","m4v","f4a","f4b","f4p","f4v","mie","qcp","asf","ogv","ogm","oga","spx","ogx","ape","wv","cur","nes","crx","ktx","dcm","mpc","arrow","shp","aac","mp1","it","s3m","xm","ai","skp","avif","eps","lzh","pgp","asar","stl","chm","3mf","zst","jxl","vcf","jls","pst","dwg","parquet","class","arj","cpio","ace","avro","icc"],"repository":{"type":"git","url":"git+https://github.com/sindresorhus/file-type.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"bugs":{"url":"https://github.com/sindresorhus/file-type/issues"},"license":"MIT","readme":"# file-type\n\n> Detect the file type of a Buffer/Uint8Array/ArrayBuffer\n\nThe file type is detected by checking the [magic number](https://en.wikipedia.org/wiki/Magic_number_(programming)#Magic_numbers_in_files) of the buffer.\n\nThis package is for detecting binary-based file formats, not text-based formats like `.txt`, `.csv`, `.svg`, etc.\n\nWe accept contributions for commonly used modern file formats, not historical or obscure ones. Open an issue first for discussion.\n\n## Install\n\n```sh\nnpm install file-type\n```\n\n**This package is a ESM package. Your project needs to be ESM too. [Read more](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c).**\n\nIf you use it with Webpack, you need the latest Webpack version and ensure you configure it correctly for ESM.\n\n## Usage\n\n#### Node.js\n\nDetermine file type from a file:\n\n```js\nimport {fileTypeFromFile} from 'file-type';\n\nconsole.log(await fileTypeFromFile('Unicorn.png'));\n//=> {ext: 'png', mime: 'image/png'}\n```\n\nDetermine file type from a Buffer, which may be a portion of the beginning of a file:\n\n```js\nimport {fileTypeFromBuffer} from 'file-type';\nimport {readChunk} from 'read-chunk';\n\nconst buffer = await readChunk('Unicorn.png', {length: 4100});\n\nconsole.log(await fileTypeFromBuffer(buffer));\n//=> {ext: 'png', mime: 'image/png'}\n```\n\nDetermine file type from a stream:\n\n```js\nimport fs from 'node:fs';\nimport {fileTypeFromStream} from 'file-type';\n\nconst stream = fs.createReadStream('Unicorn.mp4');\n\nconsole.log(await fileTypeFromStream(stream));\n//=> {ext: 'mp4', mime: 'video/mp4'}\n```\n\nThe stream method can also be used to read from a remote location:\n\n```js\nimport got from 'got';\nimport {fileTypeFromStream} from 'file-type';\n\nconst url = 'https://upload.wikimedia.org/wikipedia/en/a/a9/Example.jpg';\n\nconst stream = got.stream(url);\n\nconsole.log(await fileTypeFromStream(stream));\n//=> {ext: 'jpg', mime: 'image/jpeg'}\n```\n\nAnother stream example:\n\n```js\nimport stream from 'node:stream';\nimport fs from 'node:fs';\nimport crypto from 'node:crypto';\nimport {fileTypeStream} from 'file-type';\n\nconst read = fs.createReadStream('encrypted.enc');\nconst decipher = crypto.createDecipheriv(alg, key, iv);\n\nconst streamWithFileType = await fileTypeStream(stream.pipeline(read, decipher));\n\nconsole.log(streamWithFileType.fileType);\n//=> {ext: 'mov', mime: 'video/quicktime'}\n\nconst write = fs.createWriteStream(`decrypted.${streamWithFileType.fileType.ext}`);\nstreamWithFileType.pipe(write);\n```\n\n#### Browser\n\n```js\nimport {fileTypeFromStream} from 'file-type';\n\nconst url = 'https://upload.wikimedia.org/wikipedia/en/a/a9/Example.jpg';\n\nconst response = await fetch(url);\nconst fileType = await fileTypeFromStream(response.body);\n\nconsole.log(fileType);\n//=> {ext: 'jpg', mime: 'image/jpeg'}\n```\n\n## API\n\n### fileTypeFromBuffer(buffer)\n\nDetect the file type of a `Buffer`, `Uint8Array`, or `ArrayBuffer`.\n\nThe file type is detected by checking the [magic number](https://en.wikipedia.org/wiki/Magic_number_(programming)#Magic_numbers_in_files) of the buffer.\n\nIf file access is available, it is recommended to use `fileTypeFromFile()` instead.\n\nReturns a `Promise` for an object with the detected file type and MIME type:\n\n- `ext` - One of the [supported file types](#supported-file-types)\n- `mime` - The [MIME type](https://en.wikipedia.org/wiki/Internet_media_type)\n\nOr `undefined` when there is no match.\n\n#### buffer\n\nType: `Buffer | Uint8Array | ArrayBuffer`\n\nA buffer representing file data. It works best if the buffer contains the entire file, it may work with a smaller portion as well.\n\n### fileTypeFromFile(filePath)\n\nDetect the file type of a file path.\n\nThe file type is detected by checking the [magic number](https://en.wikipedia.org/wiki/Magic_number_(programming)#Magic_numbers_in_files) of the buffer.\n\nReturns a `Promise` for an object with the detected file type and MIME type:\n\n- `ext` - One of the [supported file types](#supported-file-types)\n- `mime` - The [MIME type](https://en.wikipedia.org/wiki/Internet_media_type)\n\nOr `undefined` when there is no match.\n\n#### filePath\n\nType: `string`\n\nThe file path to parse.\n\n### fileTypeFromStream(stream)\n\nDetect the file type of a Node.js [readable stream](https://nodejs.org/api/stream.html#stream_class_stream_readable).\n\nThe file type is detected by checking the [magic number](https://en.wikipedia.org/wiki/Magic_number_(programming)#Magic_numbers_in_files) of the buffer.\n\nReturns a `Promise` for an object with the detected file type and MIME type:\n\n- `ext` - One of the [supported file types](#supported-file-types)\n- `mime` - The [MIME type](https://en.wikipedia.org/wiki/Internet_media_type)\n\nOr `undefined` when there is no match.\n\n#### stream\n\nType: [`stream.Readable`](https://nodejs.org/api/stream.html#stream_class_stream_readable)\n\nA readable stream representing file data.\n\n### fileTypeFromBlob(blob)\n\nDetect the file type of a [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob).\n\nThe file type is detected by checking the [magic number](https://en.wikipedia.org/wiki/Magic_number_(programming)#Magic_numbers_in_files) of the buffer.\n\nReturns a `Promise` for an object with the detected file type and MIME type:\n\n- `ext` - One of the [supported file types](#supported-file-types)\n- `mime` - The [MIME type](https://en.wikipedia.org/wiki/Internet_media_type)\n\nOr `undefined` when there is no match.\n\n```js\nimport {fileTypeFromBlob} from 'file-type';\n\nconst blob = new Blob(['<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>'], {\n\ttype: 'plain/text',\n\tendings: 'native'\n});\n\nconsole.log(await fileTypeFromBlob(blob));\n//=> {ext: 'txt', mime: 'plain/text'}\n```\n\n### fileTypeFromTokenizer(tokenizer)\n\nDetect the file type from an `ITokenizer` source.\n\nThis method is used internally, but can also be used for a special \"tokenizer\" reader.\n\nA tokenizer propagates the internal read functions, allowing alternative transport mechanisms, to access files, to be implemented and used.\n\nReturns a `Promise` for an object with the detected file type and MIME type:\n\n- `ext` - One of the [supported file types](#supported-file-types)\n- `mime` - The [MIME type](https://en.wikipedia.org/wiki/Internet_media_type)\n\nOr `undefined` when there is no match.\n\nAn example is [`@tokenizer/http`](https://github.com/Borewit/tokenizer-http), which requests data using [HTTP-range-requests](https://developer.mozilla.org/en-US/docs/Web/HTTP/Range_requests). A difference with a conventional stream and the [*tokenizer*](https://github.com/Borewit/strtok3#tokenizer), is that it can *ignore* (seek, fast-forward) in the stream. For example, you may only need and read the first 6 bytes, and the last 128 bytes, which may be an advantage in case reading the entire file would take longer.\n\n```js\nimport {makeTokenizer} from '@tokenizer/http';\nimport {fileTypeFromTokenizer} from 'file-type';\n\nconst audioTrackUrl = 'https://test-audio.netlify.com/Various%20Artists%20-%202009%20-%20netBloc%20Vol%2024_%20tiuqottigeloot%20%5BMP3-V2%5D/01%20-%20Diablo%20Swing%20Orchestra%20-%20Heroines.mp3';\n\nconst httpTokenizer = await makeTokenizer(audioTrackUrl);\nconst fileType = await fileTypeFromTokenizer(httpTokenizer);\n\nconsole.log(fileType);\n//=> {ext: 'mp3', mime: 'audio/mpeg'}\n```\n\nOr use [`@tokenizer/s3`](https://github.com/Borewit/tokenizer-s3) to determine the file type of a file stored on [Amazon S3](https://aws.amazon.com/s3):\n\n```js\nimport S3 from 'aws-sdk/clients/s3';\nimport {makeTokenizer} from '@tokenizer/s3';\nimport {fileTypeFromTokenizer} from 'file-type';\n\n// Initialize the S3 client\nconst s3 = new S3();\n\n// Initialize the S3 tokenizer.\nconst s3Tokenizer = await makeTokenizer(s3, {\n\tBucket: 'affectlab',\n\tKey: '1min_35sec.mp4'\n});\n\n// Figure out what kind of file it is.\nconst fileType = await fileTypeFromTokenizer(s3Tokenizer);\nconsole.log(fileType);\n```\n\nNote that only the minimum amount of data required to determine the file type is read (okay, just a bit extra to prevent too many fragmented reads).\n\n#### tokenizer\n\nType: [`ITokenizer`](https://github.com/Borewit/strtok3#tokenizer)\n\nA file source implementing the [tokenizer interface](https://github.com/Borewit/strtok3#tokenizer).\n\n### fileTypeStream(readableStream, options?)\n\nReturns a `Promise` which resolves to the original readable stream argument, but with an added `fileType` property, which is an object like the one returned from `fileTypeFromFile()`.\n\nThis method can be handy to put in between a stream, but it comes with a price.\nInternally `stream()` builds up a buffer of `sampleSize` bytes, used as a sample, to determine the file type.\nThe sample size impacts the file detection resolution.\nA smaller sample size will result in lower probability of the best file type detection.\n\n**Note:** This method is only available when using Node.js.\n**Note:** Requires Node.js 14 or later.\n\n#### readableStream\n\nType: [`stream.Readable`](https://nodejs.org/api/stream.html#stream_class_stream_readable)\n\n#### options\n\nType: `object`\n\n##### sampleSize\n\nType: `number`\\\nDefault: `4100`\n\nThe sample size in bytes.\n\n#### Example\n\n```js\nimport got from 'got';\nimport {fileTypeStream} from 'file-type';\n\nconst url = 'https://upload.wikimedia.org/wikipedia/en/a/a9/Example.jpg';\n\nconst stream1 = got.stream(url);\nconst stream2 = await fileTypeStream(stream1, {sampleSize: 1024});\n\nif (stream2.fileType?.mime === 'image/jpeg') {\n\t// stream2 can be used to stream the JPEG image (from the very beginning of the stream)\n}\n```\n\n#### readableStream\n\nType: [`stream.Readable`](https://nodejs.org/api/stream.html#stream_class_stream_readable)\n\nThe input stream.\n\n### supportedExtensions\n\nReturns a `Set<string>` of supported file extensions.\n\n### supportedMimeTypes\n\nReturns a `Set<string>` of supported MIME types.\n\n## Supported file types\n\n- [`3g2`](https://en.wikipedia.org/wiki/3GP_and_3G2#3G2) - Multimedia container format defined by the 3GPP2 for 3G CDMA2000 multimedia services\n- [`3gp`](https://en.wikipedia.org/wiki/3GP_and_3G2#3GP) - Multimedia container format defined by the Third Generation Partnership Project (3GPP) for 3G UMTS multimedia services\n- [`3mf`](https://en.wikipedia.org/wiki/3D_Manufacturing_Format) - 3D Manufacturing Format\n- [`7z`](https://en.wikipedia.org/wiki/7z) - 7-Zip archive\n- [`Z`](https://fileinfo.com/extension/z) - Unix Compressed File\n- [`aac`](https://en.wikipedia.org/wiki/Advanced_Audio_Coding) - Advanced Audio Coding\n- [`ac3`](https://www.atsc.org/standard/a522012-digital-audio-compression-ac-3-e-ac-3-standard-12172012/) - ATSC A/52 Audio File\n- [`ace`](https://en.wikipedia.org/wiki/ACE_(compressed_file_format)) - ACE archive\n- [`ai`](https://en.wikipedia.org/wiki/Adobe_Illustrator_Artwork) - Adobe Illustrator Artwork\n- [`aif`](https://en.wikipedia.org/wiki/Audio_Interchange_File_Format) - Audio Interchange file\n- [`alias`](https://en.wikipedia.org/wiki/Alias_%28Mac_OS%29) - macOS Alias file\n- [`amr`](https://en.wikipedia.org/wiki/Adaptive_Multi-Rate_audio_codec) - Adaptive Multi-Rate audio codec\n- [`ape`](https://en.wikipedia.org/wiki/Monkey%27s_Audio) - Monkey's Audio\n- [`apng`](https://en.wikipedia.org/wiki/APNG) - Animated Portable Network Graphics\n- [`ar`](https://en.wikipedia.org/wiki/Ar_(Unix)) - Archive file\n- [`arj`](https://en.wikipedia.org/wiki/ARJ) - Archive file\n- [`arrow`](https://arrow.apache.org) - Columnar format for tables of data\n- [`arw`](https://en.wikipedia.org/wiki/Raw_image_format#ARW) - Sony Alpha Raw image file\n- [`asar`](https://github.com/electron/asar#format) - Archive format primarily used to enclose Electron applications\n- [`asf`](https://en.wikipedia.org/wiki/Advanced_Systems_Format) - Advanced Systems Format\n- [`avi`](https://en.wikipedia.org/wiki/Audio_Video_Interleave) - Audio Video Interleave file\n- [`avif`](https://en.wikipedia.org/wiki/AV1#AV1_Image_File_Format_(AVIF)) - AV1 Image File Format\n- [`avro`](https://en.wikipedia.org/wiki/Apache_Avro#Avro_Object_Container_File) - Object container file developed by Apache Avro\n- [`blend`](https://wiki.blender.org/index.php/Dev:Source/Architecture/File_Format) - Blender project\n- [`bmp`](https://en.wikipedia.org/wiki/BMP_file_format) - Bitmap image file\n- [`bpg`](https://bellard.org/bpg/) - Better Portable Graphics file\n- [`bz2`](https://en.wikipedia.org/wiki/Bzip2) - Archive file\n- [`cab`](https://en.wikipedia.org/wiki/Cabinet_(file_format)) - Cabinet file\n- [`cfb`](https://en.wikipedia.org/wiki/Compound_File_Binary_Format) - Compount File Binary Format\n- [`chm`](https://en.wikipedia.org/wiki/Microsoft_Compiled_HTML_Help) - Microsoft Compiled HTML Help\n- [`class`](https://en.wikipedia.org/wiki/Java_class_file) - Java class file\n- [`cpio`](https://en.wikipedia.org/wiki/Cpio) - Cpio archive\n- [`cr2`](https://fileinfo.com/extension/cr2) - Canon Raw image file (v2)\n- [`cr3`](https://fileinfo.com/extension/cr3) - Canon Raw image file (v3)\n- [`crx`](https://developer.chrome.com/extensions/crx) - Google Chrome extension\n- [`cur`](https://en.wikipedia.org/wiki/ICO_(file_format)) - Icon file\n- [`dcm`](https://en.wikipedia.org/wiki/DICOM#Data_format) - DICOM Image File\n- [`deb`](https://en.wikipedia.org/wiki/Deb_(file_format)) - Debian package\n- [`dmg`](https://en.wikipedia.org/wiki/Apple_Disk_Image) - Apple Disk Image\n- [`dng`](https://en.wikipedia.org/wiki/Digital_Negative) - Adobe Digital Negative image file\n- [`docx`](https://en.wikipedia.org/wiki/Office_Open_XML) - Microsoft Word\n- [`dsf`](https://dsd-guide.com/sites/default/files/white-papers/DSFFileFormatSpec_E.pdf) - Sony DSD Stream File (DSF)\n- [`dwg`](https://en.wikipedia.org/wiki/.dwg) - Autodesk CAD file\n- [`elf`](https://en.wikipedia.org/wiki/Executable_and_Linkable_Format) - Unix Executable and Linkable Format\n- [`eot`](https://en.wikipedia.org/wiki/Embedded_OpenType) - Embedded OpenType font\n- [`eps`](https://en.wikipedia.org/wiki/Encapsulated_PostScript) - Encapsulated PostScript\n- [`epub`](https://en.wikipedia.org/wiki/EPUB) - E-book file\n- [`exe`](https://en.wikipedia.org/wiki/.exe) - Executable file\n- [`f4a`](https://en.wikipedia.org/wiki/Flash_Video) - Audio-only ISO base media file format used by Adobe Flash Player\n- [`f4b`](https://en.wikipedia.org/wiki/Flash_Video) - Audiobook and podcast ISO base media file format used by Adobe Flash Player\n- [`f4p`](https://en.wikipedia.org/wiki/Flash_Video) - ISO base media file format protected by Adobe Access DRM used by Adobe Flash Player\n- [`f4v`](https://en.wikipedia.org/wiki/Flash_Video) - ISO base media file format used by Adobe Flash Player\n- [`flac`](https://en.wikipedia.org/wiki/FLAC) - Free Lossless Audio Codec\n- [`flif`](https://en.wikipedia.org/wiki/Free_Lossless_Image_Format) - Free Lossless Image Format\n- [`flv`](https://en.wikipedia.org/wiki/Flash_Video) - Flash video\n- [`gif`](https://en.wikipedia.org/wiki/GIF) - Graphics Interchange Format\n- [`glb`](https://github.com/KhronosGroup/glTF) - GL Transmission Format\n- [`gz`](https://en.wikipedia.org/wiki/Gzip) - Archive file\n- [`heic`](https://nokiatech.github.io/heif/technical.html) - High Efficiency Image File Format\n- [`icc`](https://en.wikipedia.org/wiki/ICC_profile) - ICC Profile\n- [`icns`](https://en.wikipedia.org/wiki/Apple_Icon_Image_format) - Apple Icon image\n- [`ico`](https://en.wikipedia.org/wiki/ICO_(file_format)) - Windows icon file\n- [`ics`](https://en.wikipedia.org/wiki/ICalendar#Data_format) - iCalendar\n- [`indd`](https://en.wikipedia.org/wiki/Adobe_InDesign#File_format) - Adobe InDesign document\n- [`it`](https://wiki.openmpt.org/Manual:_Module_formats#The_Impulse_Tracker_format_.28.it.29) - Audio module format: Impulse Tracker\n- [`j2c`](https://en.wikipedia.org/wiki/JPEG_2000) - JPEG 2000\n- [`jls`](https://en.wikipedia.org/wiki/Lossless_JPEG#JPEG-LS) - Lossless/near-lossless compression standard for continuous-tone images\n- [`jp2`](https://en.wikipedia.org/wiki/JPEG_2000) - JPEG 2000\n- [`jpg`](https://en.wikipedia.org/wiki/JPEG) - Joint Photographic Experts Group image\n- [`jpm`](https://en.wikipedia.org/wiki/JPEG_2000) - JPEG 2000\n- [`jpx`](https://en.wikipedia.org/wiki/JPEG_2000) - JPEG 2000\n- [`jxl`](https://en.wikipedia.org/wiki/JPEG_XL) - JPEG XL image format\n- [`jxr`](https://en.wikipedia.org/wiki/JPEG_XR) - Joint Photographic Experts Group extended range\n- [`ktx`](https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/) - OpenGL and OpenGL ES textures\n- [`lnk`](https://en.wikipedia.org/wiki/Shortcut_%28computing%29#Microsoft_Windows) - Microsoft Windows file shortcut\n- [`lz`](https://en.wikipedia.org/wiki/Lzip) - Arhive file\n- [`lzh`](https://en.wikipedia.org/wiki/LHA_(file_format)) - LZH archive\n- [`m4a`](https://en.wikipedia.org/wiki/M4A) - Audio-only MPEG-4 files\n- [`m4b`](https://en.wikipedia.org/wiki/M4B) - Audiobook and podcast MPEG-4 files, which also contain metadata including chapter markers, images, and hyperlinks\n- [`m4p`](https://en.wikipedia.org/wiki/MPEG-4_Part_14#Filename_extensions) - MPEG-4 files with audio streams encrypted by FairPlay Digital Rights Management as were sold through the iTunes Store\n- [`m4v`](https://en.wikipedia.org/wiki/M4V) - Video container format developed by Apple, which is very similar to the MP4 format\n- [`mid`](https://en.wikipedia.org/wiki/MIDI) - Musical Instrument Digital Interface file\n- [`mie`](https://en.wikipedia.org/wiki/Sidecar_file) - Dedicated meta information format which supports storage of binary as well as textual meta information\n- [`mj2`](https://en.wikipedia.org/wiki/Motion_JPEG_2000) - Motion JPEG 2000\n- [`mkv`](https://en.wikipedia.org/wiki/Matroska) - Matroska video file\n- [`mobi`](https://en.wikipedia.org/wiki/Mobipocket) - Mobipocket\n- [`mov`](https://en.wikipedia.org/wiki/QuickTime_File_Format) - QuickTime video file\n- [`mp1`](https://en.wikipedia.org/wiki/MPEG-1_Audio_Layer_I) - MPEG-1 Audio Layer I\n- [`mp2`](https://en.wikipedia.org/wiki/MPEG-1_Audio_Layer_II) - MPEG-1 Audio Layer II\n- [`mp3`](https://en.wikipedia.org/wiki/MP3) - Audio file\n- [`mp4`](https://en.wikipedia.org/wiki/MPEG-4_Part_14#Filename_extensions) - MPEG-4 Part 14 video file\n- [`mpc`](https://en.wikipedia.org/wiki/Musepack) - Musepack (SV7 & SV8)\n- [`mpg`](https://en.wikipedia.org/wiki/MPEG-1) - MPEG-1 file\n- [`mts`](https://en.wikipedia.org/wiki/.m2ts) - MPEG-2 Transport Stream, both raw and Blu-ray Disc Audio-Video (BDAV) versions\n- [`mxf`](https://en.wikipedia.org/wiki/Material_Exchange_Format) - Material Exchange Format\n- [`nef`](https://www.nikonusa.com/en/learn-and-explore/a/products-and-innovation/nikon-electronic-format-nef.html) - Nikon Electronic Format image file\n- [`nes`](https://fileinfo.com/extension/nes) - Nintendo NES ROM\n- [`odp`](https://en.wikipedia.org/wiki/OpenDocument) - OpenDocument for presentations\n- [`ods`](https://en.wikipedia.org/wiki/OpenDocument) - OpenDocument for spreadsheets\n- [`odt`](https://en.wikipedia.org/wiki/OpenDocument) - OpenDocument for word processing\n- [`oga`](https://en.wikipedia.org/wiki/Ogg) - Audio file\n- [`ogg`](https://en.wikipedia.org/wiki/Ogg) - Audio file\n- [`ogm`](https://en.wikipedia.org/wiki/Ogg) - Audio file\n- [`ogv`](https://en.wikipedia.org/wiki/Ogg) - Audio file\n- [`ogx`](https://en.wikipedia.org/wiki/Ogg) - Audio file\n- [`opus`](https://en.wikipedia.org/wiki/Opus_(audio_format)) - Audio file\n- [`orf`](https://en.wikipedia.org/wiki/ORF_format) - Olympus Raw image file\n- [`otf`](https://en.wikipedia.org/wiki/OpenType) - OpenType font\n- [`parquet`](https://en.wikipedia.org/wiki/Apache_Parquet) - Apache Parquet\n- [`pcap`](https://wiki.wireshark.org/Development/LibpcapFileFormat) - Libpcap File Format\n- [`pdf`](https://en.wikipedia.org/wiki/Portable_Document_Format) - Portable Document Format\n- [`pgp`](https://en.wikipedia.org/wiki/Pretty_Good_Privacy) - Pretty Good Privacy\n- [`png`](https://en.wikipedia.org/wiki/Portable_Network_Graphics) - Portable Network Graphics\n- [`pptx`](https://en.wikipedia.org/wiki/Office_Open_XML) - Microsoft Powerpoint\n- [`ps`](https://en.wikipedia.org/wiki/Postscript) - Postscript\n- [`psd`](https://en.wikipedia.org/wiki/Adobe_Photoshop#File_format) - Adobe Photoshop document\n- [`pst`](https://en.wikipedia.org/wiki/Personal_Storage_Table) - Personal Storage Table file\n- [`qcp`](https://en.wikipedia.org/wiki/QCP) - Tagged and chunked data\n- [`raf`](https://en.wikipedia.org/wiki/Raw_image_format) - Fujifilm RAW image file\n- [`rar`](https://en.wikipedia.org/wiki/RAR_(file_format)) - Archive file\n- [`rpm`](https://fileinfo.com/extension/rpm) - Red Hat Package Manager file\n- [`rtf`](https://en.wikipedia.org/wiki/Rich_Text_Format) - Rich Text Format\n- [`rw2`](https://en.wikipedia.org/wiki/Raw_image_format) - Panasonic RAW image file\n- [`s3m`](https://wiki.openmpt.org/Manual:_Module_formats#The_ScreamTracker_3_format_.28.s3m.29) - Audio module format: ScreamTracker 3\n- [`shp`](https://en.wikipedia.org/wiki/Shapefile) - Geospatial vector data format\n- [`skp`](https://en.wikipedia.org/wiki/SketchUp) - SketchUp\n- [`spx`](https://en.wikipedia.org/wiki/Ogg) - Audio file\n- [`sqlite`](https://www.sqlite.org/fileformat2.html) - SQLite file\n- [`stl`](https://en.wikipedia.org/wiki/STL_(file_format)) - Standard Tesselated Geometry File Format (ASCII only)\n- [`swf`](https://en.wikipedia.org/wiki/SWF) - Adobe Flash Player file\n- [`tar`](https://en.wikipedia.org/wiki/Tar_(computing)#File_format) - Tarball archive file\n- [`tif`](https://en.wikipedia.org/wiki/Tagged_Image_File_Format) - Tagged Image file\n- [`ttf`](https://en.wikipedia.org/wiki/TrueType) - TrueType font\n- [`vcf`](https://en.wikipedia.org/wiki/VCard) - vCard\n- [`voc`](https://wiki.multimedia.cx/index.php/Creative_Voice) - Creative Voice File\n- [`wasm`](https://en.wikipedia.org/wiki/WebAssembly) - WebAssembly intermediate compiled format\n- [`wav`](https://en.wikipedia.org/wiki/WAV) - Waveform Audio file\n- [`webm`](https://en.wikipedia.org/wiki/WebM) - Web video file\n- [`webp`](https://en.wikipedia.org/wiki/WebP) - Web Picture format\n- [`woff`](https://en.wikipedia.org/wiki/Web_Open_Font_Format) - Web Open Font Format\n- [`woff2`](https://en.wikipedia.org/wiki/Web_Open_Font_Format) - Web Open Font Format\n- [`wv`](https://en.wikipedia.org/wiki/WavPack) - WavPack\n- [`xcf`](https://en.wikipedia.org/wiki/XCF_(file_format)) - eXperimental Computing Facility\n- [`xlsx`](https://en.wikipedia.org/wiki/Office_Open_XML) - Microsoft Excel\n- [`xm`](https://wiki.openmpt.org/Manual:_Module_formats#The_FastTracker_2_format_.28.xm.29) - Audio module format: FastTracker 2\n- [`xml`](https://en.wikipedia.org/wiki/XML) - eXtensible Markup Language\n- [`xpi`](https://en.wikipedia.org/wiki/XPInstall) - XPInstall file\n- [`xz`](https://en.wikipedia.org/wiki/Xz) - Compressed file\n- [`zip`](https://en.wikipedia.org/wiki/Zip_(file_format)) - Archive file\n- [`zst`](https://en.wikipedia.org/wiki/Zstandard) - Archive file\n\n*Pull requests are welcome for additional commonly used file types.*\n\nThe following file types will not be accepted:\n- [MS-CFB: Microsoft Compound File Binary File Format based formats](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-cfb/53989ce4-7b05-4f8d-829b-d08d6148375b), too old and difficult to parse:\n\t- `.doc` - Microsoft Word 97-2003 Document\n\t- `.xls` - Microsoft Excel 97-2003 Document\n\t- `.ppt` - Microsoft PowerPoint97-2003 Document\n\t- `.msi` - Microsoft Windows Installer\n- `.csv` - [Reason.](https://github.com/sindresorhus/file-type/issues/264#issuecomment-568439196)\n- `.svg` - Detecting it requires a full-blown parser. Check out [`is-svg`](https://github.com/sindresorhus/is-svg) for something that mostly works.\n\n## Related\n\n- [file-type-cli](https://github.com/sindresorhus/file-type-cli) - CLI for this module\n\n## Maintainers\n\n- [Sindre Sorhus](https://github.com/sindresorhus)\n- [Borewit](https://github.com/Borewit)\n\n**Former**\n\n- [Mikael Finstad](https://github.com/mifi)\n- [Ben Brook](https://github.com/bencmbrook)\n","readmeFilename":"readme.md"}