{"name":"stream-file-type","version":"0.6.0","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":"8f610f54f25c1673c7f0c4f0febff227b765f442","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.0","_nodeVersion":"16.5.0","_npmVersion":"7.19.1","dist":{"integrity":"sha512-wDc4y/rf34RXO8rvl0WHt5oGNv7R0c4JdNFmNODnHytyzGBQK75kTh90dYVv1WCuk1k2QocSAWADioVB1TnKPA==","shasum":"401a8417a7767341321d394969e8b159cf1b989e","tarball":"http://registry-npm.ywwl.com/stream-file-type/download/stream-file-type-0.6.0.tgz","fileCount":4,"unpackedSize":5477,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg/CnBCRA9TVsSAnZWagAAIBMQAIEdIbvpMNR4+FA0hm8p\nZA1wLeWCa+mpzkKRNQ1LAPq3CY1OZCdSrok+GsgrpyUuQYt4gLUI+Oj01zH/\n+3BxP9LnsWTl3/OgQkyaFR04lJqszBGd8dtSKVC364IsaplbcEC812GkXjV9\n81Q6ugi/stiJQsV2NBY0Mww15oxv8seP5WPJke3PqxBpOikL68ZkCjLd8TOw\nlnvSZh8GVw1XDCkrRi/aDXKsUYWmoTbAtoziju8vfDy+QcJq1kHGUwZOUgTJ\nuPHOxfYC1yAgOM33+bQq03C/2Q13uBO32sg+5vWBSNf89JUKfYnuPsadaTSE\no3a5Uejhn6hcMSU6bKGDp9c92yC/6uTsbIsMjqCEV0oiiJcwJJRfvTzSmN6d\nv0NavfnoKv7FyNDjjwN/yHlGdVeCy49wXV/GI61mT8oyLk06cvBT5zftY6Wb\nEDL2CN5hwz1GHYwF6kFpoTf5xs8ftKhnfGA8TnB4uLkxHomCpBMB7PDuPN4u\nfthSqE3DEe+PVnawZxaNKrpPaWF7V8MpJ+eSQn8n2FrqL77dElP26NMD33T2\npVSfUiSpwwx7HUE8JyBZHpKohzTTzM2a1oZXkARUsVaMbdDW4YSquuoagPdQ\nt1iUwNeF+BgLVTBrgt2nT/feOtyJR3/Bdvj43cGsj43eiVnCRcQab50bz3iy\nUtSq\r\n=lIs3\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDxXPFFyH+7lczTmKr6qC+Hq4FicG5njFQ4FjMCQ697SQIhAKx5eUf+0rtvwO3fchPO4HpH0PYiMAzh9n1qEwyGytf2"}],"size":1723,"noattachment":false,"key":"/stream-file-type/-/stream-file-type-0.6.0.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.0_1627138497508_0.9859632242777467"},"_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":1627138497675,"_cnpm_publish_time":1627138497675,"dist-tags":{"latest":"0.6.1"}}