{"id":19019378,"url":"https://github.com/jshttp/media-typer","last_synced_at":"2026-05-27T23:02:55.677Z","repository":{"id":17874783,"uuid":"20814275","full_name":"jshttp/media-typer","owner":"jshttp","description":"Simple RFC 6838 media type parser and formatter","archived":false,"fork":false,"pushed_at":"2024-04-29T07:37:56.000Z","size":87,"stargazers_count":55,"open_issues_count":2,"forks_count":11,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-03-09T13:02:33.044Z","etag":null,"topics":["javascript","media","mime","nodejs","type"],"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/jshttp.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-06-13T18:47:23.000Z","updated_at":"2025-01-27T09:19:53.000Z","dependencies_parsed_at":"2024-04-22T12:28:02.862Z","dependency_job_id":"81953612-26d8-4f89-993c-e49b7415da35","html_url":"https://github.com/jshttp/media-typer","commit_stats":{"total_commits":218,"total_committers":2,"mean_commits":109.0,"dds":0.004587155963302725,"last_synced_commit":"d8c38b1afbc39e0052483d60d56646296de0f35c"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jshttp%2Fmedia-typer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jshttp%2Fmedia-typer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jshttp%2Fmedia-typer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jshttp%2Fmedia-typer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jshttp","download_url":"https://codeload.github.com/jshttp/media-typer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243695466,"owners_count":20332622,"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":["javascript","media","mime","nodejs","type"],"created_at":"2024-11-08T20:12:12.991Z","updated_at":"2026-05-27T23:02:50.655Z","avatar_url":"https://github.com/jshttp.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# media-typer\n\n[![NPM Version][npm-image]][npm-url]\n[![NPM Downloads][downloads-image]][downloads-url]\n[![Node.js Version][node-version-image]][node-version-url]\n[![Build Status][ci-image]][ci-url]\n[![Test Coverage][coveralls-image]][coveralls-url]\n\nSimple RFC 6838 media type parser.\n\nThis module will parse a given media type into its component parts, like type,\nsubtype, and suffix. A formatter is also provided to put them back together and\nthe two can be combined to normalize media types into a canonical form.\n\nIf you are looking to parse the string that represents a media type and its\nparameters in HTTP (for example, the `Content-Type` header), use the\n[content-type module](https://www.npmjs.com/package/content-type).\n\n## Installation\n\nThis is a [Node.js](https://nodejs.org/en/) module available through the\n[npm registry](https://www.npmjs.com/). Installation is done using the\n[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):\n\n```sh\n$ npm install media-typer\n```\n\n## API\n\n\u003c!-- eslint-disable no-unused-vars --\u003e\n\n```js\nvar typer = require('media-typer')\n```\n\n### typer.parse(string)\n\n\u003c!-- eslint-disable no-undef, no-unused-vars --\u003e\n\n```js\nvar obj = typer.parse('image/svg+xml')\n```\n\nParse a media type string. This will return an object with the following\nproperties (examples are shown for the string `'image/svg+xml; charset=utf-8'`):\n\n - `type`: The type of the media type (always lower case). Example: `'image'`\n\n - `subtype`: The subtype of the media type (always lower case). Example: `'svg'`\n\n - `suffix`: The suffix of the media type (always lower case). Example: `'xml'`\n\nIf the given type string is invalid, then a `TypeError` is thrown.\n\n### typer.format(obj)\n\n\u003c!-- eslint-disable no-undef, no-unused-vars --\u003e\n\n```js\nvar obj = typer.format({ type: 'image', subtype: 'svg', suffix: 'xml' })\n```\n\nFormat an object into a media type string. This will return a string of the\nmime type for the given object. For the properties of the object, see the\ndocumentation for `typer.parse(string)`.\n\nIf any of the given object values are invalid, then a `TypeError` is thrown.\n\n### typer.test(string)\n\n\u003c!-- eslint-disable no-undef, no-unused-vars --\u003e\n\n```js\nvar valid = typer.test('image/svg+xml')\n```\n\nValidate a media type string. This will return `true` if the string is a well-\nformatted media type, or `false` otherwise.\n\n## License\n\n[MIT](LICENSE)\n\n[ci-image]: https://img.shields.io/github/workflow/status/jshttp/media-typer/ci/master?label=ci\n[ci-url]: https://github.com/jshttp/media-typer/actions/workflows/ci.yml\n[npm-image]: https://img.shields.io/npm/v/media-typer.svg\n[npm-url]: https://npmjs.org/package/media-typer\n[node-version-image]: https://img.shields.io/node/v/media-typer.svg\n[node-version-url]: https://nodejs.org/en/\n[coveralls-image]: https://img.shields.io/coveralls/jshttp/media-typer/master.svg\n[coveralls-url]: https://coveralls.io/r/jshttp/media-typer?branch=master\n[downloads-image]: https://img.shields.io/npm/dm/media-typer.svg\n[downloads-url]: https://npmjs.org/package/media-typer\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjshttp%2Fmedia-typer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjshttp%2Fmedia-typer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjshttp%2Fmedia-typer/lists"}