{"name":"stream-file-type","version":"0.1.1","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":"7d47f7b6cc7c2096c0c2a022122dbd1238d4f41b","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.1","_shasum":"a4ac1a01a0ac4df39673b08908846f4cf27a15e7","_from":".","_npmVersion":"4.0.5","_nodeVersion":"7.4.0","_npmUser":{"name":"linusu","email":"linus@folkdatorn.se"},"dist":{"shasum":"a4ac1a01a0ac4df39673b08908846f4cf27a15e7","tarball":"http://registry-npm.ywwl.com/stream-file-type/download/stream-file-type-0.1.1.tgz","integrity":"sha512-/YzRoEWzWcV4E2uMh4nV0w8qhZKECdLcyRd8FOGMKXg+wzGVaF1muJR3lHvt9NLlRhEBu3gCWtmsFyX4rbm4vg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIF+yVtgyuVTbQWzEPUNo1/szLmr2LUgpMDfn1A4HG/t4AiBZ9kn/Xjn5vVitUTl1l34oxohmvqbOhW1xiP/4NZkz4A=="}],"size":35444,"noattachment":false,"key":"/stream-file-type/-/stream-file-type-0.1.1.tgz"},"maintainers":[{"name":"linusu","email":"linus@folkdatorn.se"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/stream-file-type-0.1.1.tgz_1485379493362_0.15990527207031846"},"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":1485379493897,"_cnpm_publish_time":1485379493897,"dist-tags":{"latest":"0.6.1"}}