@d1g1tal/media-type 6.0.8 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +35 -0
- package/README.md +10 -8
- package/dist/media-type.d.ts +4 -4
- package/dist/media-type.js +1 -2
- package/dist/media-type.js.map +3 -3
- package/package.json +16 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,38 @@
|
|
|
1
|
+
## [7.0.0](https://github.com/D1g1talEntr0py/media-type/compare/v6.0.8...v7.0.0) (2026-05-24)
|
|
2
|
+
|
|
3
|
+
### ⚠ BREAKING CHANGES
|
|
4
|
+
|
|
5
|
+
* **core:** The `matches()` method now checks strict equality of the media type essence rather than performing a substring match. Additionally, `type` and `subtype` properties are now exposed as read-only getters.
|
|
6
|
+
|
|
7
|
+
### Performance Improvements
|
|
8
|
+
|
|
9
|
+
* **core:** optimize parsing, serialization, and property access (f7f4479daf26d56184b0138f63bbc0adc19806db)
|
|
10
|
+
Improves parsing throughput and lowers memory footprint by switching to manual string iteration over allocating array splits/RegExp matches. Caches the computed essence and utilizes private properties to avoid object mutations post-instantiation.
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Documentation
|
|
14
|
+
|
|
15
|
+
* update license attribution to MIT (8f08552cf071dd6a6966c4f7f132e281011a6f78)
|
|
16
|
+
Modifies the README to clarify that the package is released under the MIT License instead of ISC.
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Miscellaneous Chores
|
|
20
|
+
|
|
21
|
+
* **deps-dev:** update development dependencies (1a377daf3c2d675738cde5214d5a961222793488)
|
|
22
|
+
Updates several development dependencies to their latest versions, including `@d1g1tal/tsbuild`, `@types/node`, `@typescript-eslint` packages, and `vitest` packages. This ensures the project uses up-to-date tooling with the latest features and bug fixes.
|
|
23
|
+
|
|
24
|
+
* **deps:** update dependencies, package manager, and CI workflows (67a99a633cb2814a59a70508ff4a854ff8a3631f)
|
|
25
|
+
Bumps package manager and updates various development dependencies to their latest versions to maintain security and stability. Aligns GitHub Actions workflows to use updated setup actions.
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Tests
|
|
29
|
+
|
|
30
|
+
* **bench:** add benchmarking suite and result documentation (8e1a687425e6c1667e35d0fb9162e446af3549fe)
|
|
31
|
+
Introduces a comprehensive benchmark directory employing `mitata` for rigorous performance tracking against competing implementations. Adds tracking output to demonstrate throughput gains and memory allocation improvements.
|
|
32
|
+
|
|
33
|
+
* rename parse test file for clarity (a41b2ec3b05d42e6135c2ee9f6389fb90495794f)
|
|
34
|
+
Renames `parse.test.ts` to `media-type-parser.test.ts` to better reflect the subject of the tests and align with project naming conventions.
|
|
35
|
+
|
|
1
36
|
## [6.0.8](https://github.com/D1g1talEntr0py/media-type/compare/v6.0.7...v6.0.8) (2026-04-07)
|
|
2
37
|
|
|
3
38
|
### Bug Fixes
|
package/README.md
CHANGED
|
@@ -52,9 +52,8 @@ console.assert(mediaType.parameters.get('charset') == 'utf-8');
|
|
|
52
52
|
mediaType.parameters.set('charset', 'windows-1252');
|
|
53
53
|
console.assert(mediaType.parameters.get('charset') == 'windows-1252');
|
|
54
54
|
console.assert(mediaType.toString() == 'text/html;charset=windows-1252');
|
|
55
|
-
|
|
56
|
-
console.assert(mediaType.matches('
|
|
57
|
-
console.assert(mediaType.matches('xml') == false);
|
|
55
|
+
console.assert(mediaType.matches('text/html') == true);
|
|
56
|
+
console.assert(mediaType.matches('text/xml') == false);
|
|
58
57
|
```
|
|
59
58
|
|
|
60
59
|
Parsing 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)).
|
|
@@ -83,7 +82,7 @@ if (mimeType.isHTML()) { /* ... */ }
|
|
|
83
82
|
// New (@d1g1tal/media-type v5.x)
|
|
84
83
|
import { MediaType } from '@d1g1tal/media-type';
|
|
85
84
|
const mediaType = new MediaType('text/html');
|
|
86
|
-
if (mediaType.essence === 'text/html' || mediaType.matches('html')) { /* ... */ }
|
|
85
|
+
if (mediaType.essence === 'text/html' || mediaType.matches('text/html')) { /* ... */ }
|
|
87
86
|
```
|
|
88
87
|
|
|
89
88
|
## `MediaType` API
|
|
@@ -101,7 +100,7 @@ As an alternative to the constructor, you can use `MediaType.parse(string)`. The
|
|
|
101
100
|
- `essence`: the media type's [essence](https://mimesniff.spec.whatwg.org/#mime-type-essence), e.g. `'text/html'`
|
|
102
101
|
- `parameters`: an instance of `MediaTypeParameters`, containing this media type's [parameters](https://mimesniff.spec.whatwg.org/#mime-type-parameters)
|
|
103
102
|
|
|
104
|
-
`type` and `subtype`
|
|
103
|
+
`type` and `subtype` are read-only properties exposed via getters.
|
|
105
104
|
|
|
106
105
|
`essence` is only a getter, and cannot be changed.
|
|
107
106
|
|
|
@@ -111,7 +110,7 @@ As an alternative to the constructor, you can use `MediaType.parse(string)`. The
|
|
|
111
110
|
|
|
112
111
|
- **`toString()`**: Serializes the media type to a string
|
|
113
112
|
- **`matches(mediaType: MediaType | string)`**: Checks if the media type matches the specified type
|
|
114
|
-
- When passed a string: checks
|
|
113
|
+
- When passed a string: checks exact essence equality (e.g., `mediaType.matches('text/html')` returns `true`)
|
|
115
114
|
- When passed a `MediaType` instance: performs exact type/subtype comparison
|
|
116
115
|
|
|
117
116
|
## `MediaTypeParameters` API
|
|
@@ -139,7 +138,7 @@ console.assert(mediaType.parameters.get('A') === 'b');
|
|
|
139
138
|
|
|
140
139
|
mediaType.parameters.set('Q', 'X');
|
|
141
140
|
console.assert(mediaType.parameters.get('q') === 'X');
|
|
142
|
-
console.assert(mediaType.toString() ===
|
|
141
|
+
console.assert(mediaType.toString() === "x/x;a=b;c=D;e='F';q=X");
|
|
143
142
|
|
|
144
143
|
// Throws:
|
|
145
144
|
mediaType.parameters.set('@', 'x');
|
|
@@ -192,6 +191,9 @@ pnpm build
|
|
|
192
191
|
|
|
193
192
|
# Lint
|
|
194
193
|
pnpm lint
|
|
194
|
+
|
|
195
|
+
# Run benchmarks
|
|
196
|
+
pnpm benchmark
|
|
195
197
|
```
|
|
196
198
|
|
|
197
199
|
## About This Fork
|
|
@@ -211,7 +213,7 @@ The original contributors' excellent work is acknowledged with gratitude. This f
|
|
|
211
213
|
|
|
212
214
|
## License
|
|
213
215
|
|
|
214
|
-
|
|
216
|
+
MIT License - see [LICENSE](./LICENSE) file for details.
|
|
215
217
|
|
|
216
218
|
The original `whatwg-mimetype` package was licensed under MIT.
|
|
217
219
|
|
package/dist/media-type.d.ts
CHANGED
|
@@ -73,9 +73,7 @@ declare class MediaTypeParameters extends Map<string, string> {
|
|
|
73
73
|
* @see https://mimesniff.spec.whatwg.org/#understanding-mime-types
|
|
74
74
|
*/
|
|
75
75
|
declare class MediaType {
|
|
76
|
-
private
|
|
77
|
-
private readonly _subtype;
|
|
78
|
-
private readonly _parameters;
|
|
76
|
+
#private;
|
|
79
77
|
/**
|
|
80
78
|
* Create a new MediaType instance from a string representation.
|
|
81
79
|
* @param mediaType The media type to parse.
|
|
@@ -109,7 +107,9 @@ declare class MediaType {
|
|
|
109
107
|
*/
|
|
110
108
|
get parameters(): MediaTypeParameters;
|
|
111
109
|
/**
|
|
112
|
-
* Checks if the media type matches the specified type
|
|
110
|
+
* Checks if the media type matches the specified type by essence (`type/subtype`),
|
|
111
|
+
* ignoring parameters. Comparison is case-sensitive against the lowercased essence
|
|
112
|
+
* of this instance — pass already-lowercased strings.
|
|
113
113
|
*
|
|
114
114
|
* @param mediaType The media type to check.
|
|
115
115
|
* @returns true if the media type matches the specified type, false otherwise.
|
package/dist/media-type.js
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
var
|
|
2
|
-
`,"\r"]),b=/[ \t\n\r]+$/u,f=/^[ \t\n\r]+|[ \t\n\r]+$/ug,u=class r{static parse(t){t=t.replace(f,"");let e=0,[s,i]=r.collect(t,e,["/"]);if(e=i,!s.length||e>=t.length||!o.test(s))throw new TypeError(r.generateErrorMessage("type",s));++e;let[n,a]=r.collect(t,e,[";"],!0,!0);if(e=a,!n.length||!o.test(n))throw new TypeError(r.generateErrorMessage("subtype",n));let g=new c;for(;e<t.length;){for(++e;m.has(t[e]);)++e;let l;if([l,e]=r.collect(t,e,[";","="],!1),e>=t.length||t[e]===";")continue;++e;let p;if(t[e]==='"')for([p,e]=r.collectHttpQuotedString(t,e);e<t.length&&t[e]!==";";)++e;else if([p,e]=r.collect(t,e,[";"],!1,!0),!p)continue;l&&c.isValid(l,p)&&!g.has(l)&&g.set(l,p)}return{type:s,subtype:n,parameters:g}}get[Symbol.toStringTag](){return"MediaTypeParser"}static collect(t,e,s,i=!0,n=!1){let a="";for(let{length:g}=t;e<g&&!s.includes(t[e]);e++)a+=t[e];return i&&(a=a.toLowerCase()),n&&(a=a.replace(b,"")),[a,e]}static collectHttpQuotedString(t,e){let s="";for(let i=t.length,n;++e<i&&(n=t[e])!=='"';)s+=n=="\\"&&++e<i?t[e]:n;return[s,e]}static generateErrorMessage(t,e){return`Invalid ${t} "${e}": only HTTP token code points are valid.`}};var h=class r{_type;_subtype;_parameters;constructor(t,e={}){if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError("The parameters argument must be an object");({type:this._type,subtype:this._subtype,parameters:this._parameters}=u.parse(t));for(let[s,i]of Object.entries(e))this._parameters.set(s,i)}static parse(t){try{return new r(t)}catch{}return null}get type(){return this._type}get subtype(){return this._subtype}get essence(){return`${this._type}/${this._subtype}`}get parameters(){return this._parameters}matches(t){return typeof t=="string"?this.essence.includes(t):this._type===t._type&&this._subtype===t._subtype}toString(){return`${this.essence}${this._parameters.toString()}`}get[Symbol.toStringTag](){return"MediaType"}};export{h as MediaType};
|
|
1
|
+
var l=/^[-!#$%&'*+.^_`|~A-Za-z0-9]*$/u;var T=/(["\\])/ug,A=/^[\t\u0020-\u007E\u0080-\u00FF]*$/u,f=s=>{for(let e=0,t=s.length;e<t;e++){let a=s.charCodeAt(e);if(a>=65&&a<=90)return s.toLowerCase()}return s},d=class s extends Map{constructor(e=[]){super(e)}static isValid(e,t){return l.test(e)&&A.test(t)}get(e){return super.get(f(e))}has(e){return super.has(f(e))}set(e,t){if(!s.isValid(e,t))throw new Error(`Invalid media type parameter name/value: ${e}/${t}`);return super.set(f(e),t),this}delete(e){return super.delete(f(e))}toString(){let e="";for(let[t,a]of this)e+=";",e+=t,e+="=",a.length===0||!l.test(a)?(e+='"',e+=a.replace(T,"\\$1"),e+='"'):e+=a;return e}get[Symbol.toStringTag](){return"MediaTypeParameters"}};var y=s=>s===32||s===9||s===10||s===13,M=Map.prototype.set,v=Map.prototype.has,w=class s{constructor(){}static parse(e){let t=0,a=e.length;for(;t<a&&y(e.charCodeAt(t));)t++;for(;a>t&&y(e.charCodeAt(a-1));)a--;(t!==0||a!==e.length)&&(e=e.slice(t,a));let n=e.length,r=0;for(;r<n&&e.charCodeAt(r)!==47;)r++;if(r===0||r>=n)throw new TypeError(s.#t("type",e.slice(0,r)));let i=e.slice(0,r);if(!l.test(i))throw new TypeError(s.#t("type",i));i=i.toLowerCase(),r++;let p=r;for(;r<n&&e.charCodeAt(r)!==59;)r++;let c=r;for(;c>p&&y(e.charCodeAt(c-1));)c--;if(c===p)throw new TypeError(s.#t("subtype",""));let h=e.slice(p,c);if(!l.test(h))throw new TypeError(s.#t("subtype",h));h=h.toLowerCase();let m=new d;for(;r<n;){for(r++;r<n&&y(e.charCodeAt(r));)r++;let x=r;for(;r<n;){let o=e.charCodeAt(r);if(o===59||o===61)break;r++}let b=x===r?"":e.slice(x,r);if(r>=n||e.charCodeAt(r)===59)continue;r++;let u;if(r<n&&e.charCodeAt(r)===34){r=s.#r(e,r,n),u=s.#e;let o=e.indexOf(";",r);r=o===-1?n:o}else{let o=r;for(;r<n&&e.charCodeAt(r)!==59;)r++;let g=r;for(;g>o&&y(e.charCodeAt(g-1));)g--;if(g===o)continue;u=e.slice(o,g)}if(b.length!==0&&d.isValid(b,u)){let o=b.toLowerCase();v.call(m,o)||M.call(m,o,u)}}return{type:i,subtype:h,parameters:m}}static#e="";static#r(e,t,a){t++;let n=t;for(;t<a;){let i=e.charCodeAt(t);if(i===34||i===92)break;t++}if(t>=a)return s.#e=e.slice(n,t),t;if(e.charCodeAt(t)===34)return s.#e=e.slice(n,t),t+1;let r=e.slice(n,t);for(;t<a;){let i=e.charCodeAt(t);if(i===34){t++;break}i===92&&t+1<a&&t++,r+=e[t],t++}return s.#e=r,t}static#t(e,t){return`Invalid ${e} "${t}": only HTTP token code points are valid.`}};var C=class s{#e;#r;#t;#s;constructor(e,t){if({type:this.#e,subtype:this.#r,parameters:this.#s}=w.parse(e),this.#t=this.#e+"/"+this.#r,t!==void 0){if(t===null||typeof t!="object"||Array.isArray(t))throw new TypeError("The parameters argument must be an object");for(let a in t)Object.prototype.hasOwnProperty.call(t,a)&&this.#s.set(a,t[a])}}static parse(e){try{return new s(e)}catch{}return null}get type(){return this.#e}get subtype(){return this.#r}get essence(){return this.#t}get parameters(){return this.#s}matches(e){return typeof e=="string"?this.#t===e:this.#e===e.#e&&this.#r===e.#r}toString(){return this.#t+this.#s.toString()}get[Symbol.toStringTag](){return"MediaType"}};export{C as MediaType};
|
|
3
2
|
//# sourceMappingURL=media-type.js.map
|
package/dist/media-type.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/utils.ts", "../src/media-type-parameters.ts", "../src/media-type-parser.ts", "../src/media-type.ts"],
|
|
4
|
-
"sourcesContent": ["export const httpTokenCodePoints: RegExp = /^[-!#$%&'*+.^_`|~A-Za-z0-9]*$/u;", "import { httpTokenCodePoints } from './utils.js';\n\nconst matcher: RegExp = /([\"\\\\])/ug;\nconst httpQuotedStringTokenCodePoints: RegExp = /^[\\t\\u0020-\\u007E\\u0080-\\u00FF]*$/u;\n\n/**\n * Class representing the parameters for a media type record.\n * This class extends a JavaScript Map<string, string>.\n *\n * However, MediaTypeParameters methods will always interpret their arguments\n * as appropriate for media types, so parameter names will be lowercased,\n * and attempting to set invalid characters will throw an Error.\n *\n * @see https://mimesniff.spec.whatwg.org\n * @author D1g1talEntr0py <jason.dimeo@gmail.com>\n */\nexport class MediaTypeParameters extends Map<string, string> {\n\t/**\n\t * Create a new MediaTypeParameters instance.\n\t *\n\t * @param entries An array of [ name, value ] tuples.\n\t */\n\tconstructor(entries: Iterable<[string, string]> = []) {\n\t\tsuper(entries);\n\t}\n\n\t/**\n\t * Indicates whether the supplied name and value are valid media type parameters.\n\t *\n\t * @param name The name of the media type parameter to validate.\n\t * @param value The media type parameter value to validate.\n\t * @returns true if the media type parameter is valid, false otherwise.\n\t */\n\tstatic isValid(name: string, value: string): boolean {\n\t\treturn httpTokenCodePoints.test(name) && httpQuotedStringTokenCodePoints.test(value);\n\t}\n\n\t/**\n\t * Gets the media type parameter value for the supplied name.\n\t *\n\t * @param name The name of the media type parameter to retrieve.\n\t * @returns The media type parameter value.\n\t */\n\toverride get(name: string): string | undefined {\n\t\treturn super.get(name.toLowerCase());\n\t}\n\n\t/**\n\t * Indicates whether the media type parameter with the specified name exists or not.\n\t *\n\t * @param name The name of the media type parameter to check.\n\t * @returns true if the media type parameter exists, false otherwise.\n\t */\n\toverride has(name: string): boolean {\n\t\treturn super.has(name.toLowerCase());\n\t}\n\n\t/**\n\t * Adds a new media type parameter using the specified name and value to the MediaTypeParameters.\n\t * If an parameter with the same name already exists, the parameter will be updated.\n\t *\n\t * @param name The name of the media type parameter to set.\n\t * @param value The media type parameter value.\n\t * @returns This instance.\n\t */\n\toverride set(name: string, value: string): this {\n\t\tif (!MediaTypeParameters.isValid(name, value)) {\n\t\t\tthrow new Error(`Invalid media type parameter name/value: ${name}/${value}`);\n\t\t}\n\n\t\tsuper.set(name.toLowerCase(), value);\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Removes the media type parameter using the specified name.\n\t *\n\t * @param name The name of the media type parameter to delete.\n\t * @returns true if the parameter existed and has been removed, or false if the parameter does not exist.\n\t */\n\toverride delete(name: string): boolean {\n\t\treturn super.delete(name.toLowerCase());\n\t}\n\n\t/**\n\t * Returns a string representation of the media type parameters.\n\t *\n\t * @returns The string representation of the media type parameters.\n\t */\n\toverride toString(): string {\n\t\treturn Array.from(this).map(([ name, value ]) => `;${name}=${!value || !httpTokenCodePoints.test(value) ? `\"${value.replace(matcher, '\\\\$1')}\"` : value}`).join('');\n\t}\n\n\t/**\n\t * Returns the name of this class.\n\t *\n\t * @returns The name of this class.\n\t */\n\toverride get [Symbol.toStringTag](): string {\n\t\treturn 'MediaTypeParameters';\n\t}\n}", "import { MediaTypeParameters } from './media-type-parameters.js';\nimport { httpTokenCodePoints } from './utils.js';\n\nconst whitespaceChars = new Set([' ', '\\t', '\\n', '\\r']);\nconst trailingWhitespace: RegExp = /[ \\t\\n\\r]+$/u;\nconst leadingAndTrailingWhitespace: RegExp = /^[ \\t\\n\\r]+|[ \\t\\n\\r]+$/ug;\n\nexport interface MediaTypeComponent {\n\tposition?: number;\n\tinput: string;\n\tlowerCase?: boolean;\n\ttrim?: boolean;\n}\n\nexport interface ParsedMediaType {\n\ttype: string;\n\tsubtype: string;\n\tparameters: MediaTypeParameters;\n}\n\n/**\n * Parser for media types.\n * @see https://mimesniff.spec.whatwg.org/#parsing-a-mime-type\n * @author D1g1talEntr0py <jason.dimeo@gmail.com>\n */\nexport class MediaTypeParser {\n\t/**\n\t * Function to parse a media type.\n\t * @param input The media type to parse\n\t * @returns An object populated with the parsed media type properties and any parameters.\n\t */\n\tstatic parse(input: string): ParsedMediaType {\n\t\tinput = input.replace(leadingAndTrailingWhitespace, '');\n\n\t\tlet position = 0;\n\t\tconst [ type, typeEnd ] = MediaTypeParser.collect(input, position, ['/']);\n\t\tposition = typeEnd;\n\n\t\tif (!type.length || position >= input.length || !httpTokenCodePoints.test(type)) {\n\t\t\tthrow new TypeError(MediaTypeParser.generateErrorMessage('type', type));\n\t\t}\n\n\t\t++position; // Skip \"/\"\n\t\tconst [ subtype, subtypeEnd ] = MediaTypeParser.collect(input, position, [';'], true, true);\n\t\tposition = subtypeEnd;\n\n\t\tif (!subtype.length || !httpTokenCodePoints.test(subtype)) {\n\t\t\tthrow new TypeError(MediaTypeParser.generateErrorMessage('subtype', subtype));\n\t\t}\n\n\t\tconst parameters = new MediaTypeParameters();\n\n\t\twhile (position < input.length) {\n\t\t\t++position; // Skip \";\"\n\t\t\twhile (whitespaceChars.has(input[position]!)) { ++position }\n\n\t\t\tlet name: string;\n\t\t\t[name, position] = MediaTypeParser.collect(input, position, [';', '='], false);\n\n\t\t\tif (position >= input.length || input[position] === ';') { continue }\n\n\t\t\t++position; // Skip \"=\"\n\n\t\t\tlet value: string;\n\t\t\tif (input[position] === '\"') {\n\t\t\t\t[ value, position ] = MediaTypeParser.collectHttpQuotedString(input, position);\n\t\t\t\twhile (position < input.length && input[position] !== ';') { ++position }\n\t\t\t} else {\n\t\t\t\t[ value, position ] = MediaTypeParser.collect(input, position, [';'], false, true);\n\t\t\t\tif (!value) { continue }\n\t\t\t}\n\n\t\t\tif (name && MediaTypeParameters.isValid(name, value) && !parameters.has(name)) {\n\t\t\t\tparameters.set(name, value);\n\t\t\t}\n\t\t}\n\n\t\treturn { type, subtype, parameters };\n\t}\n\n\t/**\n\t * Gets the name of this class.\n\t * @returns The string tag of this class.\n\t */\n\tget [Symbol.toStringTag](): string {\n\t\treturn 'MediaTypeParser';\n\t}\n\n\t/**\n\t * Collects characters from `input` starting at `pos` until a stop character is found.\n\t * @param input The input string.\n\t * @param pos The starting position.\n\t * @param stopChars Characters that end collection.\n\t * @param lowerCase Whether to ASCII-lowercase the result.\n\t * @param trim Whether to strip trailing HTTP whitespace.\n\t * @returns A tuple of the collected string and the updated position.\n\t */\n\tprivate static collect(input: string, pos: number, stopChars: string[], lowerCase = true, trim = false): [string, number] {\n\t\tlet result = '';\n\t\tfor (const { length } = input; pos < length && !stopChars.includes(input[pos]!); pos++) {\n\t\t\tresult += input[pos];\n\t\t}\n\n\t\tif (lowerCase) { result = result.toLowerCase() }\n\t\tif (trim) { result = result.replace(trailingWhitespace, '') }\n\n\t\treturn [result, pos];\n\t}\n\n\t/**\n\t * Collects all the HTTP quoted strings.\n\t * This variant only implements it with the extract-value flag set.\n\t * @param input The string to process.\n\t * @param position The starting position.\n\t * @returns An array that includes the resulting string and updated position.\n\t */\n\tprivate static collectHttpQuotedString(input: string, position: number): [string, number] {\n\t\tlet value = '';\n\n\t\tfor (let length = input.length, char; ++position < length;) {\n\t\t\tif ((char = input[position]) === '\"') { break }\n\n\t\t\tvalue += char == '\\\\' && ++position < length ? input[position] : char;\n\t\t}\n\n\t\treturn [ value, position ];\n\t}\n\n\t/**\n\t * Generates an error message.\n\t * @param component The component name.\n\t * @param value The component value.\n\t * @returns The error message.\n\t */\n\tprivate static generateErrorMessage(component: string, value: string): string {\n\t\treturn `Invalid ${component} \"${value}\": only HTTP token code points are valid.`;\n\t}\n}", "import { MediaTypeParser } from './media-type-parser.js';\nimport { MediaTypeParameters } from './media-type-parameters.js';\n\n/**\n * Class used to parse media types.\n * @see https://mimesniff.spec.whatwg.org/#understanding-mime-types\n */\nexport class MediaType {\n\tprivate readonly _type: string;\n\tprivate readonly _subtype: string;\n\tprivate readonly _parameters: MediaTypeParameters;\n\n\t/**\n\t * Create a new MediaType instance from a string representation.\n\t * @param mediaType The media type to parse.\n\t * @param parameters Optional parameters.\n\t */\n\tconstructor(mediaType: string, parameters: Record<string, string> = {}) {\n\t\tif (parameters === null || typeof parameters !== 'object' || Array.isArray(parameters)) {\n\t\t\tthrow new TypeError('The parameters argument must be an object');\n\t\t}\n\n\t\t({ type: this._type, subtype: this._subtype, parameters: this._parameters } = MediaTypeParser.parse(mediaType));\n\n\t\tfor (const [ name, value ] of Object.entries(parameters)) { this._parameters.set(name, value) }\n\t}\n\n\t/**\n\t * Parses a media type string.\n\t * @param mediaType The media type to parse.\n\t * @returns The parsed media type or null if the mediaType cannot be parsed.\n\t */\n\tstatic parse(mediaType: string): MediaType | null {\n\t\ttry {\n\t\t\treturn new MediaType(mediaType);\n\t\t} catch {\n\t\t\t// ignore\n\t\t}\n\n\t\treturn null;\n\t}\n\n\t/**\n\t * Gets the type.\n\t * @returns The type.\n\t */\n\tget type(): string {\n\t\treturn this._type;\n\t}\n\n\t/**\n\t * Gets the subtype.\n\t * @returns The subtype.\n\t */\n\tget subtype(): string {\n\t\treturn this._subtype;\n\t}\n\n\t/**\n\t * Gets the media type essence (type/subtype).\n\t * @returns The media type without any parameters\n\t */\n\tget essence(): string {\n\t\treturn `${this._type}/${this._subtype}`;\n\t}\n\n\t/**\n\t * Gets the parameters.\n\t * @returns The media type parameters.\n\t */\n\tget parameters(): MediaTypeParameters {\n\t\treturn this._parameters;\n\t}\n\n\t/**\n\t * Checks if the media type matches the specified type.\n\t *\n\t * @param mediaType The media type to check.\n\t * @returns true if the media type matches the specified type, false otherwise.\n\t */\n\tmatches(mediaType: MediaType | string): boolean {\n\t\treturn typeof mediaType === 'string' ? this.essence.includes(mediaType) : this._type === mediaType._type && this._subtype === mediaType._subtype;\n\t}\n\n\t/**\n\t * Gets the serialized version of the media type.\n\t *\n\t * @returns The serialized media type.\n\t */\n\ttoString(): string {\n\t\treturn `${this.essence}${this._parameters.toString()}`;\n\t}\n\n\t/**\n\t * Gets the name of the class.\n\t * @returns The class name\n\t */\n\tget [Symbol.toStringTag](): string {\n\t\treturn 'MediaType';\n\t}\n}"],
|
|
5
|
-
"mappings": "AAAO,IAAMA,EAA8B,iCCE3C,IAAMC,EAAkB,YAClBC,EAA0C,
|
|
6
|
-
"names": ["httpTokenCodePoints", "matcher", "httpQuotedStringTokenCodePoints", "MediaTypeParameters", "_MediaTypeParameters", "entries", "name", "value", "httpTokenCodePoints", "
|
|
4
|
+
"sourcesContent": ["export const httpTokenCodePoints: RegExp = /^[-!#$%&'*+.^_`|~A-Za-z0-9]*$/u;", "import { httpTokenCodePoints } from './utils.js';\n\nconst matcher: RegExp = /([\"\\\\])/ug;\nconst httpQuotedStringTokenCodePoints: RegExp = /^[\\t\\u0020-\\u007E\\u0080-\\u00FF]*$/u;\n\n/**\n * Returns the ASCII-lowercased version of `s`, or `s` itself when no characters\n * require lowering. Avoids allocating a new string when input is already lowercase.\n * @param s The string to lowercase.\n * @returns The ASCII-lowercased version of `s`.\n */\nconst asciiLower = (s: string): string => {\n\tfor (let i = 0, length = s.length; i < length; i++) {\n\t\tconst c = s.charCodeAt(i);\n\t\tif (c >= 0x41 && c <= 0x5A) { return s.toLowerCase() }\n\t}\n\n\treturn s;\n};\n\n/**\n * Class representing the parameters for a media type record.\n * This class extends a JavaScript Map<string, string>.\n *\n * However, MediaTypeParameters methods will always interpret their arguments\n * as appropriate for media types, so parameter names will be lowercased,\n * and attempting to set invalid characters will throw an Error.\n *\n * @see https://mimesniff.spec.whatwg.org\n * @author D1g1talEntr0py <jason.dimeo@gmail.com>\n */\nexport class MediaTypeParameters extends Map<string, string> {\n\t/**\n\t * Create a new MediaTypeParameters instance.\n\t *\n\t * @param entries An array of [ name, value ] tuples.\n\t */\n\tconstructor(entries: Iterable<[string, string]> = []) {\n\t\tsuper(entries);\n\t}\n\n\t/**\n\t * Indicates whether the supplied name and value are valid media type parameters.\n\t *\n\t * @param name The name of the media type parameter to validate.\n\t * @param value The media type parameter value to validate.\n\t * @returns true if the media type parameter is valid, false otherwise.\n\t */\n\tstatic isValid(name: string, value: string): boolean {\n\t\treturn httpTokenCodePoints.test(name) && httpQuotedStringTokenCodePoints.test(value);\n\t}\n\n\t/**\n\t * Gets the media type parameter value for the supplied name.\n\t *\n\t * @param name The name of the media type parameter to retrieve.\n\t * @returns The media type parameter value.\n\t */\n\toverride get(name: string): string | undefined {\n\t\treturn super.get(asciiLower(name));\n\t}\n\n\t/**\n\t * Indicates whether the media type parameter with the specified name exists or not.\n\t *\n\t * @param name The name of the media type parameter to check.\n\t * @returns true if the media type parameter exists, false otherwise.\n\t */\n\toverride has(name: string): boolean {\n\t\treturn super.has(asciiLower(name));\n\t}\n\n\t/**\n\t * Adds a new media type parameter using the specified name and value to the MediaTypeParameters.\n\t * If an parameter with the same name already exists, the parameter will be updated.\n\t *\n\t * @param name The name of the media type parameter to set.\n\t * @param value The media type parameter value.\n\t * @returns This instance.\n\t */\n\toverride set(name: string, value: string): this {\n\t\tif (!MediaTypeParameters.isValid(name, value)) {\n\t\t\tthrow new Error(`Invalid media type parameter name/value: ${name}/${value}`);\n\t\t}\n\n\t\tsuper.set(asciiLower(name), value);\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Removes the media type parameter using the specified name.\n\t *\n\t * @param name The name of the media type parameter to delete.\n\t * @returns true if the parameter existed and has been removed, or false if the parameter does not exist.\n\t */\n\toverride delete(name: string): boolean {\n\t\treturn super.delete(asciiLower(name));\n\t}\n\n\t/**\n\t * Returns a string representation of the media type parameters.\n\t *\n\t * @returns The string representation of the media type parameters.\n\t */\n\toverride toString(): string {\n\t\tlet out = '';\n\t\tfor (const [ name, value ] of this) {\n\t\t\tout += ';';\n\t\t\tout += name;\n\t\t\tout += '=';\n\t\t\tif (value.length === 0 || !httpTokenCodePoints.test(value)) {\n\t\t\t\tout += '\"';\n\t\t\t\tout += value.replace(matcher, '\\\\$1');\n\t\t\t\tout += '\"';\n\t\t\t} else {\n\t\t\t\tout += value;\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t}\n\n\t/**\n\t * Returns the name of this class.\n\t *\n\t * @returns The name of this class.\n\t */\n\toverride get [Symbol.toStringTag](): string {\n\t\treturn 'MediaTypeParameters';\n\t}\n}\n", "import { MediaTypeParameters } from './media-type-parameters.js';\nimport { httpTokenCodePoints } from './utils.js';\n\n/**\n * HTTP whitespace code points: SP (0x20), HT (0x09), LF (0x0A), CR (0x0D)\n * @see https://fetch.spec.whatwg.org/#http-whitespace\n * @param c The code point to check.\n * @returns true if the code point is HTTP whitespace, false otherwise.\n */\nconst isHttpWhitespace = (c: number): boolean => c === 0x20 || c === 0x09 || c === 0x0A || c === 0x0D;\n\n// Direct references to Map.prototype methods so we can bypass the validation/lowercase\n// performed by MediaTypeParameters.set when we already know the key is lowercased and\n// the name/value pair has been validated.\nconst mapSet = Map.prototype.set as <K, V>(this: Map<K, V>, key: K, value: V) => Map<K, V>;\nconst mapHas = Map.prototype.has as <K>(this: Map<K, unknown>, key: K) => boolean;\n\nexport interface MediaTypeComponent {\n\tposition?: number;\n\tinput: string;\n\tlowerCase?: boolean;\n\ttrim?: boolean;\n}\n\nexport interface ParsedMediaType {\n\ttype: string;\n\tsubtype: string;\n\tparameters: MediaTypeParameters;\n}\n\n/**\n * Parser for media types.\n * @see https://mimesniff.spec.whatwg.org/#parsing-a-mime-type\n * @author D1g1talEntr0py <jason.dimeo@gmail.com>\n */\nexport class MediaTypeParser {\n\tprivate constructor() {}\n\n\t/**\n\t * Function to parse a media type.\n\t * @param input The media type to parse\n\t * @returns An object populated with the parsed media type properties and any parameters.\n\t */\n\tstatic parse(input: string): ParsedMediaType {\n\t\t// Strip leading/trailing HTTP whitespace without an extra allocation when not needed.\n\t\tlet start = 0;\n\t\tlet end = input.length;\n\t\twhile (start < end && isHttpWhitespace(input.charCodeAt(start))) { start++ }\n\t\twhile (end > start && isHttpWhitespace(input.charCodeAt(end - 1))) { end-- }\n\t\tif (start !== 0 || end !== input.length) { input = input.slice(start, end) }\n\n\t\tconst length = input.length;\n\t\tlet position = 0;\n\n\t\t// Collect type up to '/'\n\t\twhile (position < length && input.charCodeAt(position) !== 0x2F /* / */) { position++ }\n\t\tif (position === 0 || position >= length) {\n\t\t\tthrow new TypeError(MediaTypeParser.#generateErrorMessage('type', input.slice(0, position)));\n\t\t}\n\t\tlet type = input.slice(0, position);\n\t\tif (!httpTokenCodePoints.test(type)) {\n\t\t\tthrow new TypeError(MediaTypeParser.#generateErrorMessage('type', type));\n\t\t}\n\t\ttype = type.toLowerCase();\n\n\t\tposition++; // Skip \"/\"\n\n\t\t// Collect subtype up to ';' (with trailing whitespace trim)\n\t\tconst subtypeStart = position;\n\t\twhile (position < length && input.charCodeAt(position) !== 0x3B /* ; */) { position++ }\n\t\tlet subtypeEnd = position;\n\t\twhile (subtypeEnd > subtypeStart && isHttpWhitespace(input.charCodeAt(subtypeEnd - 1))) { subtypeEnd-- }\n\t\tif (subtypeEnd === subtypeStart) {\n\t\t\tthrow new TypeError(MediaTypeParser.#generateErrorMessage('subtype', ''));\n\t\t}\n\t\tlet subtype = input.slice(subtypeStart, subtypeEnd);\n\t\tif (!httpTokenCodePoints.test(subtype)) {\n\t\t\tthrow new TypeError(MediaTypeParser.#generateErrorMessage('subtype', subtype));\n\t\t}\n\t\tsubtype = subtype.toLowerCase();\n\n\t\tconst parameters = new MediaTypeParameters();\n\n\t\twhile (position < length) {\n\t\t\tposition++; // Skip \";\"\n\n\t\t\t// Skip leading HTTP whitespace\n\t\t\twhile (position < length && isHttpWhitespace(input.charCodeAt(position))) { position++ }\n\n\t\t\t// Collect parameter name up to ';' or '='\n\t\t\tconst nameStart = position;\n\t\t\twhile (position < length) {\n\t\t\t\tconst c = input.charCodeAt(position);\n\t\t\t\tif (c === 0x3B /* ; */ || c === 0x3D /* = */) break;\n\t\t\t\tposition++;\n\t\t\t}\n\t\t\tconst nameRaw = nameStart === position ? '' : input.slice(nameStart, position);\n\n\t\t\tif (position >= length || input.charCodeAt(position) === 0x3B) { continue }\n\n\t\t\tposition++; // Skip \"=\"\n\n\t\t\tlet value: string;\n\t\t\tif (position < length && input.charCodeAt(position) === 0x22 /* \" */) {\n\t\t\t\tposition = MediaTypeParser.#collectHttpQuotedString(input, position, length);\n\t\t\t\tvalue = MediaTypeParser.#lastQuoted;\n\t\t\t\t// Advance to next ';'\n\t\t\t\tconst semi = input.indexOf(';', position);\n\t\t\t\tposition = semi === -1 ? length : semi;\n\t\t\t} else {\n\t\t\t\tconst valStart = position;\n\t\t\t\twhile (position < length && input.charCodeAt(position) !== 0x3B) { position++ }\n\t\t\t\tlet valEnd = position;\n\t\t\t\twhile (valEnd > valStart && isHttpWhitespace(input.charCodeAt(valEnd - 1))) { valEnd-- }\n\t\t\t\tif (valEnd === valStart) { continue }\n\t\t\t\tvalue = input.slice(valStart, valEnd);\n\t\t\t}\n\n\t\t\tif (nameRaw.length !== 0 && MediaTypeParameters.isValid(nameRaw, value)) {\n\t\t\t\tconst lower = nameRaw.toLowerCase();\n\t\t\t\tif (!mapHas.call(parameters, lower)) {\n\t\t\t\t\tmapSet.call(parameters, lower, value);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn { type, subtype, parameters };\n\t}\n\n\t// Scratch slot for the quoted-string value to avoid allocating a tuple per call.\n\tstatic #lastQuoted: string = '';\n\n\t/**\n\t * Collects an HTTP quoted-string starting at `position` (which points at the opening `\"`).\n\t * Stores the decoded value in `#lastQuoted` and returns the new position (one past the\n\t * closing `\"`, or `length` if unterminated).\n\t * @see https://httpwg.org/specs/rfc9110.html#token-syntax\n\t * @param input The full input string being parsed.\n\t * @param position The current position in the input (pointing at the opening `\"`).\n\t * @param length The length of the input string.\n\t * @returns The new position after parsing the quoted string.\n\t */\n\tstatic #collectHttpQuotedString(input: string, position: number, length: number): number {\n\t\tposition++; // skip opening \"\n\n\t\t// Fast path: scan for '\"' or '\\\\' \u2014 most quoted strings have neither.\n\t\tconst start = position;\n\t\twhile (position < length) {\n\t\t\tconst c = input.charCodeAt(position);\n\t\t\tif (c === 0x22 /* \" */ || c === 0x5C /* \\ */) break;\n\t\t\tposition++;\n\t\t}\n\n\t\tif (position >= length) {\n\t\t\tMediaTypeParser.#lastQuoted = input.slice(start, position);\n\t\t\treturn position;\n\t\t}\n\t\tif (input.charCodeAt(position) === 0x22) {\n\t\t\tMediaTypeParser.#lastQuoted = input.slice(start, position);\n\t\t\treturn position + 1;\n\t\t}\n\n\t\t// Slow path: at least one backslash. Build the rest.\n\t\tlet value = input.slice(start, position);\n\t\twhile (position < length) {\n\t\t\tconst c = input.charCodeAt(position);\n\t\t\tif (c === 0x22 /* \" */) { position++; break }\n\t\t\tif (c === 0x5C /* \\ */ && position + 1 < length) {\n\t\t\t\tposition++;\n\t\t\t\tvalue += input[position];\n\t\t\t} else {\n\t\t\t\tvalue += input[position];\n\t\t\t}\n\t\t\tposition++;\n\t\t}\n\t\tMediaTypeParser.#lastQuoted = value;\n\t\treturn position;\n\t}\n\n\t/**\n\t * Generates an error message.\n\t * @param component The component name.\n\t * @param value The component value.\n\t * @returns The error message.\n\t */\n\tstatic #generateErrorMessage(component: string, value: string): string {\n\t\treturn `Invalid ${component} \"${value}\": only HTTP token code points are valid.`;\n\t}\n}\n", "import { MediaTypeParser } from './media-type-parser.js';\nimport { MediaTypeParameters } from './media-type-parameters.js';\n\n/**\n * Class used to parse media types.\n * @see https://mimesniff.spec.whatwg.org/#understanding-mime-types\n */\nexport class MediaType {\n\treadonly #type: string;\n\treadonly #subtype: string;\n\treadonly #essence: string;\n\treadonly #parameters: MediaTypeParameters;\n\n\t/**\n\t * Create a new MediaType instance from a string representation.\n\t * @param mediaType The media type to parse.\n\t * @param parameters Optional parameters.\n\t */\n\tconstructor(mediaType: string, parameters?: Record<string, string>) {\n\t\t({ type: this.#type, subtype: this.#subtype, parameters: this.#parameters } = MediaTypeParser.parse(mediaType));\n\t\tthis.#essence = this.#type + '/' + this.#subtype;\n\n\t\tif (parameters !== undefined) {\n\t\t\tif (parameters === null || typeof parameters !== 'object' || Array.isArray(parameters)) {\n\t\t\t\tthrow new TypeError('The parameters argument must be an object');\n\t\t\t}\n\t\t\tfor (const name in parameters) {\n\t\t\t\tif (Object.prototype.hasOwnProperty.call(parameters, name)) {\n\t\t\t\t\tthis.#parameters.set(name, parameters[name]!);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Parses a media type string.\n\t * @param mediaType The media type to parse.\n\t * @returns The parsed media type or null if the mediaType cannot be parsed.\n\t */\n\tstatic parse(mediaType: string): MediaType | null {\n\t\ttry {\n\t\t\treturn new MediaType(mediaType);\n\t\t} catch {\n\t\t\t// ignore\n\t\t}\n\n\t\treturn null;\n\t}\n\n\t/**\n\t * Gets the type.\n\t * @returns The type.\n\t */\n\tget type(): string {\n\t\treturn this.#type;\n\t}\n\n\t/**\n\t * Gets the subtype.\n\t * @returns The subtype.\n\t */\n\tget subtype(): string {\n\t\treturn this.#subtype;\n\t}\n\n\t/**\n\t * Gets the media type essence (type/subtype).\n\t * @returns The media type without any parameters\n\t */\n\tget essence(): string {\n\t\treturn this.#essence;\n\t}\n\n\t/**\n\t * Gets the parameters.\n\t * @returns The media type parameters.\n\t */\n\tget parameters(): MediaTypeParameters {\n\t\treturn this.#parameters;\n\t}\n\n\t/**\n\t * Checks if the media type matches the specified type by essence (`type/subtype`),\n\t * ignoring parameters. Comparison is case-sensitive against the lowercased essence\n\t * of this instance \u2014 pass already-lowercased strings.\n\t *\n\t * @param mediaType The media type to check.\n\t * @returns true if the media type matches the specified type, false otherwise.\n\t */\n\tmatches(mediaType: MediaType | string): boolean {\n\t\treturn typeof mediaType === 'string' ? this.#essence === mediaType : this.#type === mediaType.#type && this.#subtype === mediaType.#subtype;\n\t}\n\n\t/**\n\t * Gets the serialized version of the media type.\n\t *\n\t * @returns The serialized media type.\n\t */\n\ttoString(): string {\n\t\treturn this.#essence + this.#parameters.toString();\n\t}\n\n\t/**\n\t * Gets the name of the class.\n\t * @returns The class name\n\t */\n\tget [Symbol.toStringTag](): string {\n\t\treturn 'MediaType';\n\t}\n}\n"],
|
|
5
|
+
"mappings": "AAAO,IAAMA,EAA8B,iCCE3C,IAAMC,EAAkB,YAClBC,EAA0C,qCAQ1CC,EAAc,GAAsB,CACzC,QAASC,EAAI,EAAGC,EAAS,EAAE,OAAQD,EAAIC,EAAQD,IAAK,CACnD,IAAME,EAAI,EAAE,WAAWF,CAAC,EACxB,GAAIE,GAAK,IAAQA,GAAK,GAAQ,OAAO,EAAE,YAAY,CACpD,CAEA,OAAO,CACR,EAaaC,EAAN,MAAMC,UAA4B,GAAoB,CAM5D,YAAYC,EAAsC,CAAC,EAAG,CACrD,MAAMA,CAAO,CACd,CASA,OAAO,QAAQC,EAAcC,EAAwB,CACp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AaG,EAAUH,EACpI,CAOA,UAAmB,CAClB,OAAO,KAAKC,GAAW,KAAKC,GAAY,SAAS,CAClD,CAMA,IAAK,OAAO,WAAW,GAAY,CAClC,MAAO,WACR,CACD",
|
|
6
|
+
"names": ["httpTokenCodePoints", "matcher", "httpQuotedStringTokenCodePoints", "asciiLower", "i", "length", "c", "MediaTypeParameters", "_MediaTypeParameters", "entries", "name", "value", "httpTokenCodePoints", "out", "isHttpWhitespace", "c", "mapSet", "mapHas", "MediaTypeParser", "_MediaTypeParser", "input", "start", "end", "length", "position", "#generateErrorMessage", "type", "httpTokenCodePoints", "subtypeStart", "subtypeEnd", "subtype", "parameters", "MediaTypeParameters", "nameStart", "nameRaw", "value", "#collectHttpQuotedString", "#lastQuoted", "semi", "valStart", "valEnd", "lower", "component", "MediaType", "_MediaType", "#type", "#subtype", "#essence", "#parameters", "mediaType", "parameters", "MediaTypeParser", "name"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@d1g1tal/media-type",
|
|
3
3
|
"author": "D1g1talEntr0py",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "7.0.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Parses, serializes, and manipulates media types, according to the WHATWG MIME Sniffing Standard",
|
|
7
7
|
"homepage": "https://github.com/D1g1talEntr0py/media-type#readme",
|
|
@@ -39,21 +39,21 @@
|
|
|
39
39
|
"CHANGELOG.md"
|
|
40
40
|
],
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@d1g1tal/tsbuild": "^1.
|
|
42
|
+
"@d1g1tal/tsbuild": "^1.9.0",
|
|
43
43
|
"@eslint/js": "^10.0.1",
|
|
44
|
-
"@exodus/bytes": "^1.15.
|
|
45
|
-
"@types/node": "^25.
|
|
46
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
47
|
-
"@typescript-eslint/parser": "^8.
|
|
48
|
-
"@typescript/lib-dom": "npm:@types/web@^0.0.
|
|
49
|
-
"@vitest/coverage-v8": "4.1.
|
|
50
|
-
"@vitest/ui": "^4.1.
|
|
51
|
-
"eslint": "^10.
|
|
52
|
-
"eslint-plugin-jsdoc": "^
|
|
44
|
+
"@exodus/bytes": "^1.15.1",
|
|
45
|
+
"@types/node": "^25.9.1",
|
|
46
|
+
"@typescript-eslint/eslint-plugin": "^8.59.4",
|
|
47
|
+
"@typescript-eslint/parser": "^8.59.4",
|
|
48
|
+
"@typescript/lib-dom": "npm:@types/web@^0.0.349",
|
|
49
|
+
"@vitest/coverage-v8": "4.1.7",
|
|
50
|
+
"@vitest/ui": "^4.1.7",
|
|
51
|
+
"eslint": "^10.4.0",
|
|
52
|
+
"eslint-plugin-jsdoc": "^63.0.0",
|
|
53
53
|
"printable-string": "^0.3.0",
|
|
54
|
-
"typescript": "^6.0.
|
|
55
|
-
"typescript-eslint": "^8.
|
|
56
|
-
"vitest": "^4.1.
|
|
54
|
+
"typescript": "^6.0.3",
|
|
55
|
+
"typescript-eslint": "^8.59.4",
|
|
56
|
+
"vitest": "^4.1.7"
|
|
57
57
|
},
|
|
58
58
|
"browserslist": [
|
|
59
59
|
"defaults and fully supports es6-module",
|
|
@@ -81,6 +81,7 @@
|
|
|
81
81
|
"test": "vitest run",
|
|
82
82
|
"test:watch": "vitest",
|
|
83
83
|
"test:ui": "vitest run --ui",
|
|
84
|
-
"test:coverage": "vitest run --coverage"
|
|
84
|
+
"test:coverage": "vitest run --coverage",
|
|
85
|
+
"benchmark": "pnpm build && node --import ./benchmarks/cdn-preload.ts benchmarks/benchmark.ts"
|
|
85
86
|
}
|
|
86
87
|
}
|