Gathering detailed insights and metrics for @i-xi-dev/mimetype
Gathering detailed insights and metrics for @i-xi-dev/mimetype
npm install @i-xi-dev/mimetype
Typescript
Module System
Node Version
NPM Version
TypeScript (100%)
Total Downloads
4,938
Last Day
1
Last Week
4
Last Month
24
Last Year
3,183
85 Commits
1 Watching
1 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
1.2.24
Package Id
@i-xi-dev/mimetype@1.2.24
Unpacked Size
182.61 kB
Size
39.67 kB
File Count
104
NPM Version
10.2.4
Node Version
20.11.0
Publised On
18 Jun 2024
Cumulative downloads
Total Downloads
Last day
0%
1
Compared to previous day
Last week
0%
4
Compared to previous week
Last month
-76.5%
24
Compared to previous month
Last year
338.4%
3,183
Compared to previous year
3
A JavaScript MIME type parser and serializer, implements the MIME type defined in WHATWG MIME Sniffing Standard.
Chrome | Edge | Firefox | Safari | Deno | Node.js |
---|---|---|---|---|---|
✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
1$ npm i @i-xi-dev/mimetype@1.2.24
1import { MediaType } from "@i-xi-dev/mimetype";
Example for Skypack
1import { MediaType } from "https://cdn.skypack.dev/@i-xi-dev/mimetype@1.2.24";
MediaType
classParse a MIME type string
1const mediaType = MediaType.fromString('application/soap+xml; charset=utf-8;action="https://example.com/example"'); 2 3mediaType.type; 4// → "application" 5 6mediaType.subtype; 7// → "soap+xml" 8 9mediaType.essence; 10// → "application/soap+xml" 11 12[ ...mediaType.parameterNames() ]; 13// → [ "charset", "action" ] 14 15[ ...mediaType.parameters() ]; 16// → [ ["charset", "utf-8"], ["action", "https://example.com/example"] ] 17 18mediaType.hasParameter("charset"); 19// → true 20 21mediaType.getParameterValue("action"); 22// → "https://example.com/example"
Serialize a MIME type
1const mediaType = MediaType.fromString('application/soap+xml; charset=utf-8;action="https://example.com/example"'); 2mediaType.toString(); 3// → 'application/soap+xml;charset=utf-8;action="https://example.com/example"'
Equivalent comparisons
1const mediaType = MediaType.fromString('application/soap+xml; charset=utf-8;action="https://example.com/example"'); 2 3const mediaType2 = MediaType.fromString('application/soap+xml; charset=utf-16;action="https://example.com/example"'); 4mediaType.equals(mediaType2); 5// → false 6 7const mediaType3 = MediaType.fromString('APPLICATION/SOAP+XML;ACTION="https://example.com/example";CHARSET=utf-8'); 8mediaType.equals(mediaType3); 9// → true 10 11const mediaType4 = MediaType.fromString('application/soap+xml; charset=UTF-8;action="https://example.com/example"'); 12mediaType.equals(mediaType4); 13// → false 14mediaType.equals(mediaType4, { caseInsensitiveParameters: ["charset"] }); 15// → true
Instance is immutable
1const mediaType = MediaType.fromString('application/soap+xml; charset=utf-8;action="https://example.com/example"'); 2 3const mediaType2 = mediaType.withParameters([ ["charset": "UTF-16"] ]); 4mediaType2.toString(); 5// → 'application/soap+xml;charset=UTF-16' 6const mediaType3 = mediaType.withoutParameters(); 7mediaType3.toString(); 8// → 'application/soap+xml' 9mediaType.toString(); 10// → 'application/soap+xml;charset=utf-8;action="https://example.com/example"'
No vulnerabilities found.
No security vulnerabilities found.