{"name":"stream-file-type","version":"0.1.0","license":"MIT","repository":{"type":"git","url":"git+https://github.com/linusu/stream-file-type.git"},"scripts":{"test":"standard && mocha"},"dependencies":{"file-type":"^4.1.0","readable-stream":"^2.2.2"},"devDependencies":{"hasha":"^2.2.0","mocha":"^3.2.0","standard":"^8.6.0"},"gitHead":"b38ab8453de341cf7c2ff5e58f307418a2e61611","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.1.0","_shasum":"ab0f118b6567b0d3ddbb725db20e2e30b681e46c","_from":".","_npmVersion":"4.0.5","_nodeVersion":"7.4.0","_npmUser":{"name":"linusu","email":"linus@folkdatorn.se"},"dist":{"shasum":"ab0f118b6567b0d3ddbb725db20e2e30b681e46c","tarball":"http://registry-npm.ywwl.com/stream-file-type/download/stream-file-type-0.1.0.tgz","integrity":"sha512-+U3f35asNqPMT5ptAEAAbtuRnpZG/s9c6K7pPvxScHuQ9vJkGGqXElGGfkiza7FRiw8NdfCw+IDkCVkyDP/QTA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD94AVhCc1WH+T2Yvt8LMxH/3uf6NBd2Big4D1tyaIojAIhAJpIehX/ckuUfJSFubVQZII0FU+NQImVpb7txnIQMtkw"}],"size":35382,"noattachment":false,"key":"/stream-file-type/-/stream-file-type-0.1.0.tgz"},"maintainers":[{"name":"linusu","email":"linus@folkdatorn.se"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/stream-file-type-0.1.0.tgz_1485376291776_0.19189019477926195"},"directories":{},"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":1485376292331,"_cnpm_publish_time":1485376292331,"dist-tags":{"latest":"0.6.1"}}