{"_id":"fast-content-type-parse@4.0.0","bugs":{"url":"https://github.com/fastify/fast-content-type-parse/issues"},"dist":{"shasum":"3d46bee110cc6e0d94a6c249385ace46b36b8313","tarball":"http://registry-npm.ywwl.com/fast-content-type-parse/download/fast-content-type-parse-4.0.0.tgz","fileCount":20,"integrity":"sha512-rvu3AY9s3EsDXSDUWzFU5M9/fDpjAUwyIkDR9VrwZA3H9J5f4ymkT0J4iWw9iLaMvFVwsYTGFClUgy9VIvnabA==","signatures":[{"sig":"MEUCIAGseYVhbV7QALCdlBsvSt+6hzzcVGfSnUmXc6VXCZgzAiEAxWjIclky/KhE7jOmdMbQfef06rVYbQcknReW5bEkozs=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCID+aJQR3gooiMpuf7qVqTPTY2JkMd9aTubKzNdFixmzMAiEA5tpy0ePAyZiUp4bsCmv+LbtwcIFyRbWpt+3VcHXHFPQ="}],"unpackedSize":37966,"size":9366,"noattachment":false,"key":"/fast-content-type-parse/-/fast-content-type-parse-4.0.0.tgz"},"main":"index.js","name":"fast-content-type-parse","type":"commonjs","types":"./types/index.d.ts","author":{"name":"Aras Abbasi","email":"aras.abbasi@gmail.com"},"funding":[{"url":"https://github.com/sponsors/fastify","type":"github"},{"url":"https://opencollective.com/fastify","type":"opencollective"}],"gitHead":"9af615489daccab421908701a95a2ee18a618dda","license":"MIT","scripts":{"lint":"eslint","test":"npm run test:unit && npm run test:typescript","lint:fix":"eslint --fix","benchmark":"node benchmarks/simple.js && node benchmarks/simple-ows.js && node benchmarks/with-param.js && node benchmarks/with-param-quoted.js","test:unit":"c8 --100 node --test","jazzer:errors":"npm rebuild @jazzer.js/core && jazzer benchmarks/fuzzer-check-errors --sync --timeout=100 -- -max_total_time=120","test:typescript":"tstyche","jazzer:performance":"npm rebuild @jazzer.js/core && jazzer benchmarks/fuzzer-check-performance --sync --timeout=100 -- -max_total_time=120"},"version":"4.0.0","_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"homepage":"https://github.com/fastify/fast-content-type-parse#readme","keywords":["content-type","rfc9110"],"repository":{"url":"git+https://github.com/fastify/fast-content-type-parse.git","type":"git"},"_npmVersion":"11.16.0","description":"Parse HTTP Content-Type header according to RFC 9110","directories":{},"maintainers":[{"name":"eomm","email":"behemoth89@gmail.com"},{"name":"gurgunday","email":"hey@gurgun.day"},{"name":"ivan-tymoshenko","email":"ivan@tymoshenko.me"},{"name":"climba03003","email":"kaka@kakawebsitedemo.com"},{"name":"jsumners","email":"james.sumners@gmail.com"},{"name":"fdawgs","email":"frazer.dev@icloud.com"},{"name":"matteo.collina","email":"hello@matteocollina.com"},{"name":"uzlopak","email":"aras.abbasi@googlemail.com"}],"_nodeVersion":"24.18.0","contributors":[{"url":"https://heyhey.to/G","name":"Gürgün Dayıoğlu","email":"hey@gurgun.day"},{"name":"Manuel Spigolon","email":"behemoth89@gmail.com"},{"url":"https://james.sumners.info","name":"James Sumners"},{"url":"https://github.com/fdawgs","name":"Frazer Smith","email":"frazer.dev@icloud.com"}],"_hasShrinkwrap":false,"devDependencies":{"c8":"^12.0.0","busboy":"^1.6.0","eslint":"^9.17.0","tstyche":"^7.0.0","benchmark":"^2.1.4","neostandard":"^0.13.0","content-type":"^3.0.0","@jazzer.js/core":"^4.0.0"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/fast-content-type-parse_4.0.0_1788254799807_0.25515571374124346"},"readme":"# fast-content-type-parse\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[![CI](https://github.com/fastify/fast-content-type-parse/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/fastify/fast-content-type-parse/actions/workflows/ci.yml)\n[![neostandard javascript style](https://img.shields.io/badge/code_style-neostandard-brightgreen?style=flat)](https://github.com/neostandard/neostandard)\n[![Security Responsible Disclosure](https://img.shields.io/badge/Security-Responsible%20Disclosure-yellow.svg)](https://github.com/fastify/.github/blob/main/SECURITY.md)\n\nParse HTTP Content-Type header according to [RFC 9110](https://www.rfc-editor.org/rfc/rfc9110#section-8.3.1).\n\n## Installation\n\n```sh\nnpm 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 lowercase).\n   Example: `'application/json'`\n\n- `parameters`: An object of the parameters in the media type (name of parameter\n   always lowercase). 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 lowercase).\n   Example: `'application/json'`\n\n- `parameters`: An object of the parameters in the media type (name of parameter\n   always lowercase). 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## Grammar\n\nThe parser implements the `media-type` grammar of\n[RFC 9110 Section 8.3.1](https://www.rfc-editor.org/rfc/rfc9110#section-8.3.1)\nexactly, without extensions:\n\n```\nmedia-type      = type \"/\" subtype parameters\ntype            = token\nsubtype         = token\nparameters      = *( OWS \";\" OWS [ parameter ] )\nparameter       = parameter-name \"=\" parameter-value\nparameter-name  = token\nparameter-value = ( token / quoted-string )\nOWS             = *( SP / HTAB )\n```\n\nIn particular:\n\n- Only spaces and horizontal tabs (`OWS`) are accepted around the media type\n  and the `;` separators. Any other whitespace, including `CR`, `LF` and\n  Unicode whitespace, is rejected.\n- Empty parameters (`text/html;`, `text/html; ; charset=utf-8`) are accepted,\n  as allowed by RFC 9110.\n- `type`, `subtype` and parameter names are case-insensitive and are\n  lower-cased. Parameter values are returned as-is.\n- Quoted-pairs in `quoted-string` values are unescaped.\n- When a parameter appears more than once, the first occurrence wins, matching\n  `util.MIMEType`, the [WHATWG MIME Sniffing Standard](https://mimesniff.spec.whatwg.org/#parsing-a-mime-type)\n  and the `content-type` package.\n- `parameters` is a null-prototype object, so parameter names such as\n  `__proto__` or `constructor` are ordinary keys.\n\n## Benchmarks\n\n```sh\nnpm run benchmark\n\nBenchmarking: \"application/json; charset=utf-8\"\nutil#MIMEType x 2,637,188 ops/sec ±0.95% (93 runs sampled)\nfast-content-type-parse#parse x 5,165,077 ops/sec ±0.75% (95 runs sampled)\nfast-content-type-parse#safeParse x 5,189,599 ops/sec ±0.72% (94 runs sampled)\ncontent-type#parse x 4,227,069 ops/sec ±0.79% (96 runs sampled)\nbusboy#parseContentType x 777,787 ops/sec ±0.75% (91 runs sampled)\nFastest is fast-content-type-parse#safeParse,fast-content-type-parse#parse\n```\n\n## Credits\n\nBased on the npm package `content-type`.\n\n## License\n\nLicensed under [MIT](./LICENSE).\n","publish_time":1788254799899,"_cnpm_publish_time":1788254799899,"dist-tags":{"latest":"4.0.1"}}