{"id":22733475,"url":"https://github.com/strikeentco/mime-kind","last_synced_at":"2025-04-14T01:54:24.834Z","repository":{"id":47980767,"uuid":"43219638","full_name":"strikeentco/mime-kind","owner":"strikeentco","description":"Detect the mime type of a Buffer, ReadStream, file path and file name.","archived":false,"fork":false,"pushed_at":"2023-01-09T16:43:07.000Z","size":301,"stargazers_count":9,"open_issues_count":6,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-14T01:54:17.800Z","etag":null,"topics":["buffer","filetype","javascript","mime-types","nodejs","stream"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/strikeentco.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-09-26T19:28:37.000Z","updated_at":"2024-08-07T10:37:29.000Z","dependencies_parsed_at":"2023-02-08T13:01:28.749Z","dependency_job_id":null,"html_url":"https://github.com/strikeentco/mime-kind","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strikeentco%2Fmime-kind","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strikeentco%2Fmime-kind/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strikeentco%2Fmime-kind/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strikeentco%2Fmime-kind/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/strikeentco","download_url":"https://codeload.github.com/strikeentco/mime-kind/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248809032,"owners_count":21164895,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["buffer","filetype","javascript","mime-types","nodejs","stream"],"created_at":"2024-12-10T20:14:44.020Z","updated_at":"2025-04-14T01:54:24.811Z","avatar_url":"https://github.com/strikeentco.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"mime-kind [![License](https://img.shields.io/npm/l/mime-kind.svg)](https://github.com/strikeentco/mime-kind/blob/master/LICENSE) [![npm](https://img.shields.io/npm/v/mime-kind.svg)](https://www.npmjs.com/package/mime-kind)\n==========\n[![Build Status](https://travis-ci.org/strikeentco/mime-kind.svg)](https://travis-ci.org/strikeentco/mime-kind) [![node](https://img.shields.io/node/v/mime-kind.svg)](https://www.npmjs.com/package/mime-kind) [![Test Coverage](https://api.codeclimate.com/v1/badges/5c3c2bdb323d9132a2f4/test_coverage)](https://codeclimate.com/github/strikeentco/mime-kind/test_coverage)\n\nDetect the MIME type of a `Buffer`, `Uint8Array`, `ArrayBuffer`, `ReadableStream`, file path and file name, with `async` method.\n\n## Install\n```sh\n$ npm install mime-kind --save\n```\n\n## Usage\n\n```js\nconst { createReadStream } = require('fs');\nconst mime = require('mime-kind');\n\nawait mime('.fakeext'); // -\u003e null\nawait mime(createReadStream('./anonim.jpg')); // -\u003e { ext: 'jpeg', mime: 'image/jpeg' }\nawait mime('c:/anonim.jpeg'); // -\u003e { ext: 'jpeg', mime: 'image/jpeg' }\n```\n\n## API\n\n### mime(input, [defaultValue])\n### mime.async(input, [defaultValue])\n\nReturns a `Promise` with an object (or `null` when no match) with:\n\n* `ext` - file type\n* `mime` - the [MIME type](http://en.wikipedia.org/wiki/Internet_media_type)\n\nThis methods supports all kind of `ReadableStreams`.\n\n### Params:\n\n* **input** (*String|Buffer|Uint8Array|ArrayBuffer|ReadableStream*) - `Buffer`, `Uint8Array`, `ArrayBuffer`, `ReadableStream`, file path or file name.\n* **[defaultValue]** (*String|Object*) - `String` or `Object` with value which will be returned if no match will be found. If `defaultValue` is incorrect returns `null`.\n\n```js\nconst mime = require('mime-kind');\n\nawait mime('.fakeext', 'application/octet-stream'); // -\u003e { ext: 'bin', mime: 'application/octet-stream' }\nawait mime.async('.fakeext', { ext: 'mp4', mime: 'video/mp4' }); // -\u003e { ext: 'mp4', mime: 'video/mp4' }\nawait mime.async('.fakeext', 'ogg'); // -\u003e { ext: 'ogg', mime: 'audio/ogg' }\n// but\nawait mime.async('.fakeext', 'ogg3'); // -\u003e null\nawait mime('.fakeext', { ext: 'fake', mime: 'fake/fake' }); // -\u003e null\n```\n\nWith `HTTP(S)` streams:\n```js\nconst mime = require('mime-kind');\nconst { get } = require('https');\nconst { PassThrough } = require('stream');\n\nconst pass = new PassThrough();\nget('https://avatars0.githubusercontent.com/u/2401029', res =\u003e res.pipe(pass));\nawait mime(pass); // -\u003e { ext: 'jpg', mime: 'image/jpeg' }\n```\n\n## License\n\nThe MIT License (MIT)\u003cbr/\u003e\nCopyright (c) 2015-2022 Alexey Bystrov\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstrikeentco%2Fmime-kind","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstrikeentco%2Fmime-kind","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstrikeentco%2Fmime-kind/lists"}