{"name":"fast-content-type-parse","version":"2.0.0","keywords":["content-type","rfc7231"],"author":{"name":"Aras Abbasi","email":"aras.abbasi@gmail.com"},"license":"MIT","_id":"fast-content-type-parse@2.0.0","homepage":"https://github.com/fastify/fast-content-type-parse#readme","bugs":{"url":"https://github.com/fastify/fast-content-type-parse/issues"},"dist":{"shasum":"dea7bfd385e4f18e69f37d309431a4b48470fece","tarball":"http://registry-npm.ywwl.com/fast-content-type-parse/download/fast-content-type-parse-2.0.0.tgz","fileCount":21,"integrity":"sha512-fCqg/6Sps8tqk8p+kqyKqYfOF0VjPNYrqpLiqNl0RBKmD80B080AJWVV6EkSkscjToNExcXg1+Mfzftrx6+iSA==","signatures":[{"sig":"MEUCIBC1D2LCFkMSEFb9I1RnLPEIV0HPVahppSz1HXG4Qf32AiEAwmrAsJc3oHUE7KGtq7VNdVxSEvIgwsy51n11OU6sECA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20910,"size":6020,"noattachment":false,"key":"/fast-content-type-parse/-/fast-content-type-parse-2.0.0.tgz"},"main":"index.js","type":"commonjs","types":"./types/index.d.ts","gitHead":"398557785f83b0f6d3acb836541545dfc7933c6e","scripts":{"lint":"standard","test":"npm run test:unit && npm run test:typescript","lint:fix":"standard --fix","benchmark":"node benchmarks/simple.js && node benchmarks/simple-ows.js && node benchmarks/with-param.js && node benchmarks/with-param-quoted.js","test:unit":"tap","test:typescript":"tsd"},"_npmUser":{"name":"jsumners","email":"james.sumners@gmail.com"},"pre-commit":["lint","test"],"repository":{"url":"git+https://github.com/fastify/fast-content-type-parse.git","type":"git"},"_npmVersion":"10.7.0","description":"Parse HTTP Content-Type header according to RFC 7231","directories":{},"_nodeVersion":"20.15.0","_hasShrinkwrap":false,"devDependencies":{"tap":"^19.2.5","tsd":"^0.31.0","busboy":"^1.6.0","standard":"^17.0.0","benchmark":"^2.1.4","content-type":"^1.0.4","@fastify/pre-commit":"^2.1.0"},"_npmOperationalInternal":{"tmp":"tmp/fast-content-type-parse_2.0.0_1720904000981_0.2831613639666848","host":"s3://npm-registry-packages"},"readme":"# fast-content-type-parse\n\nParse HTTP Content-Type header according to RFC 7231\n\n<div align=\"center\">\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</div>\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","publish_time":1720904001156,"maintainers":[{"email":"frazer.dev@icloud.com","name":"fdawgs"},{"email":"james.sumners@gmail.com","name":"jsumners"},{"email":"kaka@kakawebsitedemo.com","name":"climba03003"},{"email":"hey@gurgun.day","name":"gurgunday"},{"email":"simone.busoli@gmail.com","name":"simoneb"},{"email":"ivan@tymoshenko.me","name":"ivan-tymoshenko"},{"email":"behemoth89@gmail.com","name":"eomm"},{"email":"vince.legoff@gmail.com","name":"zekth"},{"email":"rafael.nunu@hotmail.com","name":"rafaelgss"},{"email":"hello@matteocollina.com","name":"matteo.collina"},{"email":"aras.abbasi@googlemail.com","name":"uzlopak"}],"_cnpm_publish_time":1720904001156,"dist-tags":{"latest":"4.0.1"}}