{"name":"stream-file-type","version":"0.6.1","license":"MIT","repository":{"type":"git","url":"git+https://github.com/LinusU/stream-file-type.git"},"type":"module","exports":"./index.js","scripts":{"test":"standard && mocha"},"dependencies":{"file-type":"^16.0.0"},"devDependencies":{"hasha":"^5.2.2","mocha":"^9.0.2","standard":"^16.0.3"},"engines":{"node":"^12.20.0 || ^14.13.1 || >=16.0.0"},"gitHead":"ead179f7e1be04974c29bf605a76831c07ce3cf8","description":"Get the [file type](https://github.com/sindresorhus/file-type) by inspecting a stream.","bugs":{"url":"https://github.com/LinusU/stream-file-type/issues"},"homepage":"https://github.com/LinusU/stream-file-type#readme","_id":"stream-file-type@0.6.1","_nodeVersion":"16.5.0","_npmVersion":"7.19.1","dist":{"integrity":"sha512-//KIXMQan4ow4gD//dfPu15nhH/sFdt41PzAOpD9EBFUBy/MtFjocTPO8v1dTOJnyi47TlPo6Qj+67sSE1lJKA==","shasum":"d8b8ac8736a0f2df7ca3e5718e28b6e8187f78fe","tarball":"http://registry-npm.ywwl.com/stream-file-type/download/stream-file-type-0.6.1.tgz","fileCount":4,"unpackedSize":5440,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg/DpQCRA9TVsSAnZWagAAkcIP/RoLwwBG2j1shbUV0Kbh\nFGTHPU9de0ix7jhLFaxBbcW2Z7uEOgrr9FW3Zenj7B6ShvYb0sml8E4kjvqh\nEfPv8IJO1TNGGO4FidfLt/yGL93/Pxw3Wg7yZqKj9B0+7JItecwZU/+KpJ0f\nGI+HVKJRCgXlhoa7KR+qj+Ao+EWTruoBwQsRiG+GDQI/SXfJRWju6HlfKCL5\n8gskkIucHxWszdknGIIcZEnNBnnbiVzjfEWi/+OQ7K8n5VRR6l6nsbQ90x8J\nQDiActmnZFvgdH4+5Oaz0F+8veKUgheDOG0fTRfOKFxchgRm31vIR4YGQlBA\nt/WZD8HAMTkgjpVRokiZHmakQCOUAbNLi1zJ/WEUO/y/vcFfhuFyVWlJJeV4\nBVvUDfBTVdwCmoBJ2SCyBYuU3oG2PyMGVXeWdUZFDDYUYp+Rvct0y75wdM1f\nNhPBxkOxzGuTTQwL/dy99PpLqSNPzjjXkgaZANE887tDY2CPzfcd0UVqLLAH\n27Ipuu/vkVy+t0ffgM4onY8k8Bu/+uMdrV47fEuvU4fQvnpNfNN3xOXpsbFC\nJt+EPzNoLNdTNMvs95CCMfN2o68r2T8Hqb/TAPK01usxxftz+oWHmeicTlHr\nbTd0tX9DEmP8D5ZsUHMFz24WkiZOicwXAXxW0tSjrKL8qlzx8+oOpF1AYjrP\nheym\r\n=60YC\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDhkAl4ql9w+WO6pd8aBBOzGIl7kPEJMTO6KtxqCbsi9AiEAudTFCow3UK0GFY2QEMPcxFTdc77EF0WK49k7wxaZDb4="}],"size":1723,"noattachment":false,"key":"/stream-file-type/-/stream-file-type-0.6.1.tgz"},"_npmUser":{"name":"linusu","email":"linus@folkdatorn.se"},"directories":{},"maintainers":[{"name":"linusu","email":"linus@folkdatorn.se"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/stream-file-type_0.6.1_1627142736247_0.01686400858588155"},"_hasShrinkwrap":false,"readme":"# Stream File Type\n\nGet the [file type](https://github.com/sindresorhus/file-type) by inspecting a stream.\n\n## Usage\n\n```js\nimport fs from 'node:fs'\nimport FileType from 'stream-file-type'\n\nconst input = fs.createReadStream('cat.jpg')\nconst detector = new FileType()\n\n// Listen for event...\ndetector.on('file-type', (fileType) => {\n  if (fileType === null) {\n    console.log(`The mime type of \"cat.jpg\" could not be determined`)\n  } else {\n    console.log(`The file \"cat.jpg\" has the \"${fileType.mime}\" mime type`)\n  }\n})\n\n// ...or get a Promise\ndetector.fileTypePromise().then((fileType) => {\n  if (fileType === null) {\n    console.log(`The mime type of \"cat.jpg\" could not be determined`)\n  } else {\n    console.log(`The file \"cat.jpg\" has the \"${fileType.mime}\" mime type`)\n  }\n})\n\ninput.pipe(detector).resume()\n```\n\n## API\n\n### `new FileType() => DuplexStream`\n\nReturns a new `DuplexStream` that will detect the file type of the content passing thru. All the data is passed as-is right thru the stream, and can be further piped to another destination.\n\nWhen enough bytes have come thru to determine the file type (currently 4100) the event `file-type` will be emitted with the result of the detection. The result will either be `null` or an object with `ext` and `mime`.\n\n- `ext` - One of the [supported file types](https://github.com/sindresorhus/file-type#supported-file-types)\n- `mime` - The [MIME type](http://en.wikipedia.org/wiki/Internet_media_type)\n\n### `FileType#fileTypePromise() => Promise`\n\nReturns a `Promise` of the detected file type. If the `file-type` event has already been emitted, the promise will be resolved with the result, otherwise the promise will be resolved when the file-type is detected.\n","publish_time":1627142736405,"_cnpm_publish_time":1627142736405,"dist-tags":{"latest":"0.6.1"}}