{"id":14969143,"url":"https://github.com/fastify/fast-content-type-parse","last_synced_at":"2025-10-19T09:32:21.381Z","repository":{"id":66129613,"uuid":"585860994","full_name":"fastify/fast-content-type-parse","owner":"fastify","description":"Parse HTTP Content-Type header according to RFC 7231","archived":false,"fork":false,"pushed_at":"2024-08-01T08:13:30.000Z","size":36,"stargazers_count":4,"open_issues_count":1,"forks_count":2,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-09-28T11:20:58.519Z","etag":null,"topics":["fastify","fastify-library"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fastify.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"fastify","open_collective":"fastify"}},"created_at":"2023-01-06T09:23:43.000Z","updated_at":"2024-08-01T08:13:27.000Z","dependencies_parsed_at":"2024-01-23T20:11:10.262Z","dependency_job_id":"4847d299-c0f3-4e50-af69-1a5cb07a9e09","html_url":"https://github.com/fastify/fast-content-type-parse","commit_stats":{"total_commits":32,"total_committers":7,"mean_commits":4.571428571428571,"dds":0.59375,"last_synced_commit":"a7faec2062cb9560460a12438091d5042b771da1"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":"fastify/skeleton","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastify%2Ffast-content-type-parse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastify%2Ffast-content-type-parse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastify%2Ffast-content-type-parse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastify%2Ffast-content-type-parse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fastify","download_url":"https://codeload.github.com/fastify/fast-content-type-parse/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219869246,"owners_count":16555572,"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":["fastify","fastify-library"],"created_at":"2024-09-24T13:41:12.152Z","updated_at":"2025-10-19T09:32:16.128Z","avatar_url":"https://github.com/fastify.png","language":"JavaScript","funding_links":["https://github.com/sponsors/fastify","https://opencollective.com/fastify"],"categories":[],"sub_categories":[],"readme":"# fast-content-type-parse\n\nParse HTTP Content-Type header according to RFC 7231\n\n\u003cdiv align=\"center\"\u003e\n\n[![NPM version](https://img.shields.io/npm/v/fast-content-type-parse.svg?style=flat)](https://www.npmjs.com/package/fast-content-type-parse)\n[![NPM downloads](https://img.shields.io/npm/dm/fast-content-type-parse.svg?style=flat)](https://www.npmjs.com/package/fast-content-type-parse)\n[![Build Status](https://github.com/fastify/fast-content-type-parse/workflows/CI/badge.svg)](https://github.com/fastify/fast-content-type-parse/actions)\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://standardjs.com/)\n[![Security Responsible Disclosure](https://img.shields.io/badge/Security-Responsible%20Disclosure-yellow.svg)](https://github.com/fastify/.github/blob/main/SECURITY.md)\n\n\u003c/div\u003e\n\n## Installation\n\n```sh\n$ npm install fast-content-type-parse\n```\n\n## Usage\n\n```js\nconst fastContentTypeParse = require('fast-content-type-parse')\n```\n\n### fastContentTypeParse.parse(string)\n\n```js\nconst contentType = fastContentTypeParse.parse('application/json; charset=utf-8')\n```\n\nParse a `Content-Type` header. Throws a `TypeError` if the string is invalid.\n\nIt will return an object with the following properties (examples are shown for\nthe string `'application/json; charset=utf-8'`):\n\n - `type`: The media type (the type and subtype, always lower case).\n   Example: `'application/json'`\n\n - `parameters`: An object of the parameters in the media type (name of parameter\n   always lower case). Example: `{charset: 'utf-8'}`\n\n### fastContentTypeParse.safeParse(string)\n\n```js\nconst contentType = fastContentTypeParse.safeParse('application/json; charset=utf-8')\n```\n\nParse a `Content-Type` header. It will not throw an Error if the header is invalid.\n\nThis will return an object with the following\nproperties (examples are shown for the string `'application/json; charset=utf-8'`):\n\n - `type`: The media type (the type and subtype, always lower case).\n   Example: `'application/json'`\n\n - `parameters`: An object of the parameters in the media type (name of parameter\n   always lower case). Example: `{charset: 'utf-8'}`\n\nIn case the header is invalid, it will return an object\nwith an empty string `''` as type and an empty Object for `parameters`.\n\n## Benchmarks\n\n```sh\nnode benchmarks/index.js\nutil#MIMEType x 1,206,781 ops/sec ±0.22% (96 runs sampled)\nfast-content-type-parse#parse x 3,752,236 ops/sec ±0.42% (96 runs sampled)\nfast-content-type-parse#safeParse x 3,675,645 ops/sec ±1.09% (94 runs sampled)\ncontent-type#parse x 1,452,582 ops/sec ±0.37% (95 runs sampled)\nbusboy#parseContentType x 924,306 ops/sec ±0.43% (94 runs sampled)\nFastest is fast-content-type-parse#parse\n```\n\n## Credits\n\nBased on the npm package `content-type`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffastify%2Ffast-content-type-parse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffastify%2Ffast-content-type-parse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffastify%2Ffast-content-type-parse/lists"}