{"_id":"whatwg-mimetype","_rev":"178162","name":"whatwg-mimetype","description":"Parses, serializes, and manipulates MIME types, according to the WHATWG MIME Sniffing Standard","dist-tags":{"latest":"3.0.0"},"maintainers":[{"name":"domenic","email":""},{"name":"joris-van-der-wel","email":""},{"name":"sebmaster","email":""},{"name":"timothygu","email":""},{"name":"tmpvar","email":""},{"name":"zirro","email":""}],"time":{"modified":"2022-10-18T09:28:16.000Z","created":"2017-12-10T06:29:12.340Z","3.0.0":"2021-09-18T19:28:10.916Z","2.3.0":"2018-11-20T23:56:53.400Z","2.2.0":"2018-09-14T18:39:05.267Z","2.1.0":"2018-02-04T20:02:32.142Z","2.0.1":"2017-12-10T16:58:32.866Z","2.0.0":"2017-12-10T06:29:12.340Z"},"users":{},"author":{"name":"Domenic Denicola","email":"d@domenic.me","url":"https://domenic.me/"},"repository":{"type":"git","url":"git+https://github.com/jsdom/whatwg-mimetype.git"},"versions":{"3.0.0":{"name":"whatwg-mimetype","description":"Parses, serializes, and manipulates MIME types, according to the WHATWG MIME Sniffing Standard","keywords":["content-type","mime type","mimesniff","http","whatwg"],"version":"3.0.0","author":{"name":"Domenic Denicola","email":"d@domenic.me","url":"https://domenic.me/"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/jsdom/whatwg-mimetype.git"},"main":"lib/mime-type.js","scripts":{"test":"jest","coverage":"jest --coverage","lint":"eslint .","pretest":"node scripts/get-latest-platform-tests.js"},"devDependencies":{"@domenic/eslint-config":"^1.4.0","eslint":"^7.32.0","jest":"^27.2.0","minipass-fetch":"^1.4.1","printable-string":"^0.3.0","whatwg-encoding":"^2.0.0"},"engines":{"node":">=12"},"jest":{"coverageDirectory":"coverage","coverageReporters":["lcov","text-summary"],"testEnvironment":"node","testMatch":["<rootDir>/test/**/*.js"]},"gitHead":"e68afa4a11909575daf67b41061b251c61c8135d","bugs":{"url":"https://github.com/jsdom/whatwg-mimetype/issues"},"homepage":"https://github.com/jsdom/whatwg-mimetype#readme","_id":"whatwg-mimetype@3.0.0","_nodeVersion":"16.4.1","_npmVersion":"7.18.1","dist":{"shasum":"5fa1a7623867ff1af6ca3dc72ad6b8a4208beba7","size":5309,"noattachment":false,"key":"/whatwg-mimetype/-/whatwg-mimetype-3.0.0.tgz","tarball":"http://name.csiicloud.com:7001/whatwg-mimetype/download/whatwg-mimetype-3.0.0.tgz"},"_npmUser":{"name":"domenic","email":"d@domenic.me"},"directories":{},"maintainers":[{"name":"domenic","email":""},{"name":"joris-van-der-wel","email":""},{"name":"sebmaster","email":""},{"name":"timothygu","email":""},{"name":"tmpvar","email":""},{"name":"zirro","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/whatwg-mimetype_3.0.0_1631993290786_0.9050839752369897"},"_hasShrinkwrap":false,"publish_time":1631993290916,"_cnpm_publish_time":1631993290916,"_cnpmcore_publish_time":"2021-12-16T10:07:32.354Z"},"2.3.0":{"name":"whatwg-mimetype","description":"Parses, serializes, and manipulates MIME types, according to the WHATWG MIME Sniffing Standard","keywords":["content-type","mime type","mimesniff","http","whatwg"],"version":"2.3.0","author":{"name":"Domenic Denicola","email":"d@domenic.me","url":"https://domenic.me/"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/jsdom/whatwg-mimetype.git"},"main":"lib/mime-type.js","scripts":{"test":"jest","coverage":"jest --coverage","lint":"eslint .","pretest":"node scripts/get-latest-platform-tests.js"},"devDependencies":{"eslint":"^5.9.0","jest":"^23.6.0","printable-string":"^0.3.0","request":"^2.88.0","whatwg-encoding":"^1.0.5"},"jest":{"coverageDirectory":"coverage","coverageReporters":["lcov","text-summary"],"testEnvironment":"node","testMatch":["<rootDir>/test/**/*.js"]},"gitHead":"7eadb26d8e02f9d95bc2f6e272df7eb653d7a903","bugs":{"url":"https://github.com/jsdom/whatwg-mimetype/issues"},"homepage":"https://github.com/jsdom/whatwg-mimetype#readme","_id":"whatwg-mimetype@2.3.0","_npmVersion":"6.2.0","_nodeVersion":"10.8.0","_npmUser":{"name":"domenic","email":"d@domenic.me"},"dist":{"shasum":"3d4b1e0312d2079879f826aff18dbeeca5960fbf","size":5135,"noattachment":false,"key":"/whatwg-mimetype/-/whatwg-mimetype-2.3.0.tgz","tarball":"http://name.csiicloud.com:7001/whatwg-mimetype/download/whatwg-mimetype-2.3.0.tgz"},"maintainers":[{"name":"domenic","email":""},{"name":"joris-van-der-wel","email":""},{"name":"sebmaster","email":""},{"name":"timothygu","email":""},{"name":"tmpvar","email":""},{"name":"zirro","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/whatwg-mimetype_2.3.0_1542758213289_0.1704504739378121"},"_hasShrinkwrap":false,"publish_time":1542758213400,"_cnpm_publish_time":1542758213400,"_cnpmcore_publish_time":"2021-12-16T10:07:32.534Z"},"2.2.0":{"name":"whatwg-mimetype","description":"Parses, serializes, and manipulates MIME types, according to the WHATWG MIME Sniffing Standard","keywords":["content-type","mime type","mimesniff","http","whatwg"],"version":"2.2.0","author":{"name":"Domenic Denicola","email":"d@domenic.me","url":"https://domenic.me/"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/jsdom/whatwg-mimetype.git"},"main":"lib/mime-type.js","scripts":{"test":"jest","coverage":"jest --coverage","lint":"eslint .","pretest":"node scripts/get-latest-platform-tests.js"},"devDependencies":{"eslint":"^5.5.0","jest":"^23.6.0","printable-string":"^0.3.0","request":"^2.88.0","whatwg-encoding":"^1.0.4"},"jest":{"coverageDirectory":"coverage","coverageReporters":["lcov","text-summary"],"testEnvironment":"node","testMatch":["<rootDir>/test/**/*.js"]},"gitHead":"426bf68a22d51f9647d57c05f038e310c1444e98","bugs":{"url":"https://github.com/jsdom/whatwg-mimetype/issues"},"homepage":"https://github.com/jsdom/whatwg-mimetype#readme","_id":"whatwg-mimetype@2.2.0","_npmVersion":"6.2.0","_nodeVersion":"10.8.0","_npmUser":{"name":"domenic","email":"d@domenic.me"},"dist":{"shasum":"a3d58ef10b76009b042d03e25591ece89b88d171","size":5141,"noattachment":false,"key":"/whatwg-mimetype/-/whatwg-mimetype-2.2.0.tgz","tarball":"http://name.csiicloud.com:7001/whatwg-mimetype/download/whatwg-mimetype-2.2.0.tgz"},"maintainers":[{"name":"domenic","email":""},{"name":"joris-van-der-wel","email":""},{"name":"sebmaster","email":""},{"name":"timothygu","email":""},{"name":"tmpvar","email":""},{"name":"zirro","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/whatwg-mimetype_2.2.0_1536950345140_0.7309741373150824"},"_hasShrinkwrap":false,"publish_time":1536950345267,"_cnpm_publish_time":1536950345267,"_cnpmcore_publish_time":"2021-12-16T10:07:32.763Z"},"2.1.0":{"name":"whatwg-mimetype","description":"Parses, serializes, and manipulates MIME types, according to the WHATWG MIME Sniffing Standard","keywords":["content-type","mime type","mimesniff","http","whatwg"],"version":"2.1.0","author":{"name":"Domenic Denicola","email":"d@domenic.me","url":"https://domenic.me/"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/jsdom/whatwg-mimetype.git"},"main":"lib/mime-type.js","files":["lib/"],"scripts":{"test":"jest","coverage":"jest --coverage","lint":"eslint .","pretest":"node scripts/get-latest-platform-tests.js"},"devDependencies":{"eslint":"^4.12.1","jest":"^21.2.1","printable-string":"^0.3.0","request":"^2.83.0","whatwg-encoding":"^1.0.3"},"jest":{"coverageDirectory":"coverage","coverageReporters":["lcov","text-summary"],"testEnvironment":"node","testMatch":["<rootDir>/test/**/*.js"]},"gitHead":"220d674c39e75ac5a3afacc6003bfb5e34c88485","bugs":{"url":"https://github.com/jsdom/whatwg-mimetype/issues"},"homepage":"https://github.com/jsdom/whatwg-mimetype#readme","_id":"whatwg-mimetype@2.1.0","_npmVersion":"5.6.0","_nodeVersion":"8.9.4","_npmUser":{"name":"domenic","email":"d@domenic.me"},"dist":{"shasum":"f0f21d76cbba72362eb609dbed2a30cd17fcc7d4","size":5137,"noattachment":false,"key":"/whatwg-mimetype/-/whatwg-mimetype-2.1.0.tgz","tarball":"http://name.csiicloud.com:7001/whatwg-mimetype/download/whatwg-mimetype-2.1.0.tgz"},"maintainers":[{"name":"domenic","email":""},{"name":"joris-van-der-wel","email":""},{"name":"sebmaster","email":""},{"name":"timothygu","email":""},{"name":"tmpvar","email":""},{"name":"zirro","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/whatwg-mimetype-2.1.0.tgz_1517774551100_0.22127527836710215"},"directories":{},"publish_time":1517774552142,"_hasShrinkwrap":false,"_cnpm_publish_time":1517774552142,"_cnpmcore_publish_time":"2021-12-16T10:07:32.981Z"},"2.0.1":{"name":"whatwg-mimetype","description":"Parses, serializes, and manipulates MIME types, according to the WHATWG MIME Sniffing Standard","keywords":["content-type","mime type","mimesniff","http","whatwg"],"version":"2.0.1","author":{"name":"Domenic Denicola","email":"d@domenic.me","url":"https://domenic.me/"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/jsdom/whatwg-mimetype.git"},"main":"lib/mime-type.js","files":["lib/"],"scripts":{"test":"jest","coverage":"jest --coverage","lint":"eslint .","pretest":"node scripts/get-latest-platform-tests.js"},"devDependencies":{"eslint":"^4.12.1","jest":"^21.2.1","printable-string":"^0.3.0","request":"^2.83.0","whatwg-encoding":"^1.0.3"},"jest":{"coverageDirectory":"coverage","coverageReporters":["lcov","text-summary"],"testEnvironment":"node","testMatch":["<rootDir>/test/**/*.js"]},"gitHead":"341d94b03efd3ba17bf6c0d9043872c05e405ff4","bugs":{"url":"https://github.com/jsdom/whatwg-mimetype/issues"},"homepage":"https://github.com/jsdom/whatwg-mimetype#readme","_id":"whatwg-mimetype@2.0.1","_npmVersion":"5.4.2","_nodeVersion":"8.6.0","_npmUser":{"name":"domenic","email":"d@domenic.me"},"dist":{"shasum":"781d925257d973e720ea0001779b2ea86a03caae","size":4674,"noattachment":false,"key":"/whatwg-mimetype/-/whatwg-mimetype-2.0.1.tgz","tarball":"http://name.csiicloud.com:7001/whatwg-mimetype/download/whatwg-mimetype-2.0.1.tgz"},"maintainers":[{"name":"domenic","email":""},{"name":"joris-van-der-wel","email":""},{"name":"sebmaster","email":""},{"name":"timothygu","email":""},{"name":"tmpvar","email":""},{"name":"zirro","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/whatwg-mimetype-2.0.1.tgz_1512925111943_0.3966343451756984"},"directories":{},"publish_time":1512925112866,"_hasShrinkwrap":false,"_cnpm_publish_time":1512925112866,"_cnpmcore_publish_time":"2021-12-16T10:07:33.211Z"},"2.0.0":{"name":"whatwg-mimetype","description":"Parses, serializes, and manipulates MIME types, according to the WHATWG MIME Sniffing Standard","keywords":["content-type","mime type","mimesniff","http","whatwg"],"version":"2.0.0","author":{"name":"Domenic Denicola","email":"d@domenic.me","url":"https://domenic.me/"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/jsdom/whatwg-mimetype.git"},"main":"lib/mime-type.js","files":["lib/"],"scripts":{"test":"jest","coverage":"jest --coverage","lint":"eslint .","pretest":"node scripts/get-latest-platform-tests.js"},"devDependencies":{"eslint":"^4.12.1","jest":"^21.2.1","printable-string":"^0.3.0","request":"^2.83.0","whatwg-encoding":"^1.0.3"},"jest":{"coverageDirectory":"coverage","coverageReporters":["lcov","text-summary"],"testEnvironment":"node","testMatch":["<rootDir>/test/**/*.js"]},"gitHead":"4f9c1e4119bea535cb91c76fead464db82cf2d67","bugs":{"url":"https://github.com/jsdom/whatwg-mimetype/issues"},"homepage":"https://github.com/jsdom/whatwg-mimetype#readme","_id":"whatwg-mimetype@2.0.0","_npmVersion":"5.4.2","_nodeVersion":"8.6.0","_npmUser":{"name":"domenic","email":"d@domenic.me"},"dist":{"shasum":"552b7b120f98d93b0f1477a757ad1451aadb9cc1","size":4703,"noattachment":false,"key":"/whatwg-mimetype/-/whatwg-mimetype-2.0.0.tgz","tarball":"http://name.csiicloud.com:7001/whatwg-mimetype/download/whatwg-mimetype-2.0.0.tgz"},"maintainers":[{"name":"domenic","email":""},{"name":"joris-van-der-wel","email":""},{"name":"sebmaster","email":""},{"name":"timothygu","email":""},{"name":"tmpvar","email":""},{"name":"zirro","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/whatwg-mimetype-2.0.0.tgz_1512887351332_0.5732134545687586"},"directories":{},"publish_time":1512887352340,"_hasShrinkwrap":false,"_cnpm_publish_time":1512887352340,"_cnpmcore_publish_time":"2021-12-16T10:07:33.432Z"}},"readme":"# Parse, serialize, and manipulate MIME types\n\nThis package will parse [MIME types](https://mimesniff.spec.whatwg.org/#understanding-mime-types) into a structured format, which can then be manipulated and serialized:\n\n```js\nconst MIMEType = require(\"whatwg-mimetype\");\n\nconst mimeType = new MIMEType(`Text/HTML;Charset=\"utf-8\"`);\n\nconsole.assert(mimeType.toString() === \"text/html;charset=utf-8\");\n\nconsole.assert(mimeType.type === \"text\");\nconsole.assert(mimeType.subtype === \"html\");\nconsole.assert(mimeType.essence === \"text/html\");\nconsole.assert(mimeType.parameters.get(\"charset\") === \"utf-8\");\n\nmimeType.parameters.set(\"charset\", \"windows-1252\");\nconsole.assert(mimeType.parameters.get(\"charset\") === \"windows-1252\");\nconsole.assert(mimeType.toString() === \"text/html;charset=windows-1252\");\n\nconsole.assert(mimeType.isHTML() === true);\nconsole.assert(mimeType.isXML() === false);\n```\n\nParsing is a fairly complex process; see [the specification](https://mimesniff.spec.whatwg.org/#parsing-a-mime-type) for details (and similarly [for serialization](https://mimesniff.spec.whatwg.org/#serializing-a-mime-type)).\n\nThis package's algorithms conform to those of the WHATWG [MIME Sniffing Standard](https://mimesniff.spec.whatwg.org/), and is aligned up to commit [8e9a7dd](https://github.com/whatwg/mimesniff/commit/8e9a7dd90717c595a4e4d982cd216e4411d33736).\n\n## `MIMEType` API\n\nThis package's main module's default export is a class, `MIMEType`. Its constructor takes a string which it will attempt to parse into a MIME type; if parsing fails, an `Error` will be thrown.\n\n### The `parse()` static factory method\n\nAs an alternative to the constructor, you can use `MIMEType.parse(string)`. The only difference is that `parse()` will return `null` on failed parsing, whereas the constructor will throw. It thus makes the most sense to use the constructor in cases where unparseable MIME types would be exceptional, and use `parse()` when dealing with input from some unconstrained source.\n\n### Properties\n\n- `type`: the MIME type's [type](https://mimesniff.spec.whatwg.org/#mime-type-type), e.g. `\"text\"`\n- `subtype`: the MIME type's [subtype](https://mimesniff.spec.whatwg.org/#mime-type-subtype), e.g. `\"html\"`\n- `essence`: the MIME type's [essence](https://mimesniff.spec.whatwg.org/#mime-type-essence), e.g. `\"text/html\"`\n- `parameters`: an instance of `MIMETypeParameters`, containing this MIME type's [parameters](https://mimesniff.spec.whatwg.org/#mime-type-parameters)\n\n`type` and `subtype` can be changed. They will be validated to be non-empty and only contain [HTTP token code points](https://mimesniff.spec.whatwg.org/#http-token-code-point).\n\n`essence` is only a getter, and cannot be changed.\n\n`parameters` is also a getter, but the contents of the `MIMETypeParameters` object are mutable, as described below.\n\n### Methods\n\n- `toString()` serializes the MIME type to a string\n- `isHTML()`: returns true if this instance represents [a HTML MIME type](https://mimesniff.spec.whatwg.org/#html-mime-type)\n- `isXML()`: returns true if this instance represents [an XML MIME type](https://mimesniff.spec.whatwg.org/#xml-mime-type)\n- `isJavaScript({ prohibitParameters })`: returns true if this instance represents [a JavaScript MIME type](https://html.spec.whatwg.org/multipage/scripting.html#javascript-mime-type). `prohibitParameters` can be set to true to disallow any parameters, i.e. to test if the MIME type's serialization is a [JavaScript MIME type essence match](https://mimesniff.spec.whatwg.org/#javascript-mime-type-essence-match).\n\n_Note: the `isHTML()`, `isXML()`, and `isJavaScript()` methods are speculative, and may be removed or changed in future major versions. See [whatwg/mimesniff#48](https://github.com/whatwg/mimesniff/issues/48) for brainstorming in this area. Currently we implement these mainly because they are useful in jsdom._\n\n## `MIMETypeParameters` API\n\nThe `MIMETypeParameters` class, instances of which are returned by `mimeType.parameters`, has equivalent surface API to a [JavaScript `Map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map).\n\nHowever, `MIMETypeParameters` methods will always interpret their arguments as appropriate for MIME types, so e.g. parameter names will be lowercased, and attempting to set invalid characters will throw.\n\nSome examples:\n\n```js\nconst mimeType = new MIMEType(`x/x;a=b;c=D;E=\"F\"`);\n\n// Logs:\n// a b\n// c D\n// e F\nfor (const [name, value] of mimeType.parameters) {\n  console.log(name, value);\n}\n\nconsole.assert(mimeType.parameters.has(\"a\"));\nconsole.assert(mimeType.parameters.has(\"A\"));\nconsole.assert(mimeType.parameters.get(\"A\") === \"b\");\n\nmimeType.parameters.set(\"Q\", \"X\");\nconsole.assert(mimeType.parameters.get(\"q\") === \"X\");\nconsole.assert(mimeType.toString() === \"x/x;a=b;c=d;e=F;q=X\");\n\n// Throws:\nmimeType.parameters.set(\"@\", \"x\");\n```\n\n## Raw parsing/serialization APIs\n\nIf you want primitives on which to build your own API, you can get direct access to the parsing and serialization algorithms as follows:\n\n```js\nconst parse = require(\"whatwg-mimetype/parser\");\nconst serialize = require(\"whatwg-mimetype/serialize\");\n```\n\n`parse(string)` returns an object containing the `type` and `subtype` strings, plus `parameters`, which is a `Map`. This is roughly our equivalent of the spec's [MIME type record](https://mimesniff.spec.whatwg.org/#mime-type). If parsing fails, it instead returns `null`.\n\n`serialize(record)` operates on the such an object, giving back a string according to the serialization algorithm.\n","_attachments":{},"homepage":"https://github.com/jsdom/whatwg-mimetype#readme","bugs":{"url":"https://github.com/jsdom/whatwg-mimetype/issues"},"license":"MIT"}