@d1g1tal/media-type 6.0.0 → 6.0.2

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 CHANGED
@@ -1,3 +1,254 @@
1
+ ## [6.0.2](https://github.com/D1g1talEntr0py/media-type/compare/v6.0.1...v6.0.2) (2026-03-02)
2
+
3
+ ### Bug Fixes
4
+
5
+ * version bump due to Claude mistake. Oops! (1752b078a6fe162e3f7837cdf02af4d62c9f3d05)
6
+
7
+ ### Documentation
8
+
9
+ * fixed license file (e52439d82791806dac633ffae1e7c6891677e40e)
10
+ * fixed license file, again (44dd9ccc6e6be8cb8b2ea29c7bb44f6daebf98fc)
11
+
12
+ ## [6.0.1](https://github.com/D1g1talEntr0py/media-type/compare/v6.0.0...v6.0.1) (2026-03-01)
13
+
14
+ ### Bug Fixes
15
+
16
+ * **ci:** add workflow_dispatch trigger, correct tarball glob, and add type-check script (a46c2c19baf6c49b3b4e57da3e36de08a6df9e1f)
17
+
18
+ ### Code Refactoring
19
+
20
+ * **parser:** simplify component collection API (681e8f275b46cc39a6f146f1bcdddd85a277136a)
21
+ Replaces the options-object-based filterComponent method with a
22
+ straighter collect function returning a tuple, eliminating unnecessary
23
+ parameter grouping and making call sites easier to read.
24
+
25
+ Switches the whitespace character lookup from an array (O(n) includes)
26
+ to a Set (O(1) has) for a small but consistent performance gain.
27
+
28
+
29
+ ### Documentation
30
+
31
+ * update README badges and fix minor formatting (51cf9457fc604cccde032c060ecb86bf876a9713)
32
+ Replaces static badge URLs with dynamic ones that show live npm download
33
+ counts and the new CI/Codecov status badges, giving visitors an
34
+ immediate signal of project health.
35
+
36
+ Fixes trailing-whitespace and import-block formatting issues.
37
+
38
+
39
+ ### Miscellaneous Chores
40
+
41
+ * **release:** 5.1.0 [skip ci] (f3c6cbffe6ed87a59a5c7b321fc69d269ac61d28)
42
+ ## [5.1.0](https://github.com/D1g1talEntr0py/media-type/compare/v5.0.0...v5.1.0) (2026-03-01)
43
+
44
+ ### Features
45
+
46
+ * convert to TypeScript (06901a60aa3d0643815e5f3c53d934f2dae0b361)
47
+
48
+ ### Code Refactoring
49
+
50
+ * **parser:** simplify component collection API (681e8f275b46cc39a6f146f1bcdddd85a277136a)
51
+ Replaces the options-object-based filterComponent method with a
52
+ straighter collect function returning a tuple, eliminating unnecessary
53
+ parameter grouping and making call sites easier to read.
54
+
55
+ Switches the whitespace character lookup from an array (O(n) includes)
56
+ to a Set (O(1) has) for a small but consistent performance gain.
57
+
58
+ ### Documentation
59
+
60
+ * update README badges and fix minor formatting (51cf9457fc604cccde032c060ecb86bf876a9713)
61
+ Replaces static badge URLs with dynamic ones that show live npm download
62
+ counts and the new CI/Codecov status badges, giving visitors an
63
+ immediate signal of project health.
64
+
65
+ Fixes trailing-whitespace and import-block formatting issues.
66
+
67
+ ### Miscellaneous Chores
68
+
69
+ * upgrade dev dependencies to latest versions (6b54d8b1cddf7dbc824dba54fd5933570b66a262)
70
+ Bumps eslint to v10, typescript-eslint to 8.56, vitest/coverage-v8/ui
71
+ to 4.0.18, @types/node to 25, @types/web to 0.0.338, and several
72
+ transitive deps (esbuild, rollup, vite, acorn, ajv, etc.).
73
+
74
+ Adds @d1g1tal/tsbuild as the project build tool, replacing the previous
75
+ build setup, and introduces a type-check script. Removes the duplicate
76
+ coverage script alias. Sets the minimum Node.js engine to >=20.16.0.
77
+
78
+ Updates .gitignore to track .tsbuild/ output directory.
79
+
80
+ ### Build System
81
+
82
+ * add semantic-release config and release docs (1cdaab0d9db81c363cf1d81e8ae36e758b2b7c57)
83
+ Adds a .releaserc.json that configures semantic-release with the
84
+ conventionalcommits preset, custom release rules (refactor triggers a
85
+ patch bump), grouped changelog sections, npm pack + publish with
86
+ provenance, and a git commit of CHANGELOG.md and package.json after
87
+ each release.
88
+
89
+ Adds a release-process.md guide explaining how to author commits,
90
+ open PRs, merge to main, and verify the automated release, including
91
+ a dry-run section and a troubleshooting FAQ.
92
+
93
+ ### Continuous Integration
94
+
95
+ * add GitHub Actions workflows for CI and release (4ad266f7984742e7c5dd722340dc3c0786e4c7c9)
96
+ Adds a CI workflow that runs lint, type-check, tests with coverage, and
97
+ build across Node.js 20, 22, and 24 on every push and pull request to
98
+ main. Coverage is uploaded to Codecov from the Node 24 run only.
99
+
100
+ Adds a release workflow powered by semantic-release that triggers on
101
+ merges to main and fully automates versioning, changelog generation, npm
102
+ publish with provenance, and GitHub Release creation.
103
+
104
+ Adds a commit-msg git hook that enforces Conventional Commits format so
105
+ that semantic-release can reliably determine version bumps.
106
+
107
+ * add packageManager field for pnpm/action-setup (ee441628159346a66013bb429bf30e583d687b03)
108
+ * trigger actions (836151dd5d4e73e3bf51f2a6d5b11f462eef25a8)
109
+ * trigger actions (c415c4a08169fa103acbaaa9a1268485df6eb4e0)
110
+ * trigger actions (fc350c91e7e2546604361aade7f0f55530095b38)
111
+
112
+ * **release:** 5.1.1 [skip ci] (f4d1336e1031a2d42ff9e2f091019ae0bb90d5f5)
113
+ ## [5.1.1](https://github.com/D1g1talEntr0py/media-type/compare/v5.1.0...v5.1.1) (2026-03-01)
114
+
115
+ ### Bug Fixes
116
+
117
+ * **ci:** add workflow_dispatch trigger, correct tarball glob, and add type-check script (a46c2c19baf6c49b3b4e57da3e36de08a6df9e1f)
118
+
119
+ ### Tests
120
+
121
+ * removed web-platform-tests from .gitignore (db2fbdd787928e9b5ac2661bd4a738221f084280)
122
+
123
+ ### Continuous Integration
124
+
125
+ * added missing test data (12d03ca176a8c4407610774e599325df7790e0bc)
126
+
127
+ * restore correct version and revert bad 5.1.1 changelog entry (c47f3bf32826152f6f6b363e4ed63a9d61ea61dd)
128
+ * upgrade dev dependencies to latest versions (6b54d8b1cddf7dbc824dba54fd5933570b66a262)
129
+ Bumps eslint to v10, typescript-eslint to 8.56, vitest/coverage-v8/ui
130
+ to 4.0.18, @types/node to 25, @types/web to 0.0.338, and several
131
+ transitive deps (esbuild, rollup, vite, acorn, ajv, etc.).
132
+
133
+ Adds @d1g1tal/tsbuild as the project build tool, replacing the previous
134
+ build setup, and introduces a type-check script. Removes the duplicate
135
+ coverage script alias. Sets the minimum Node.js engine to >=20.16.0.
136
+
137
+ Updates .gitignore to track .tsbuild/ output directory.
138
+
139
+
140
+ ### Tests
141
+
142
+ * removed web-platform-tests from .gitignore (db2fbdd787928e9b5ac2661bd4a738221f084280)
143
+
144
+ ### Build System
145
+
146
+ * add semantic-release config and release docs (1cdaab0d9db81c363cf1d81e8ae36e758b2b7c57)
147
+ Adds a .releaserc.json that configures semantic-release with the
148
+ conventionalcommits preset, custom release rules (refactor triggers a
149
+ patch bump), grouped changelog sections, npm pack + publish with
150
+ provenance, and a git commit of CHANGELOG.md and package.json after
151
+ each release.
152
+
153
+ Adds a release-process.md guide explaining how to author commits,
154
+ open PRs, merge to main, and verify the automated release, including
155
+ a dry-run section and a troubleshooting FAQ.
156
+
157
+
158
+ ### Continuous Integration
159
+
160
+ * add GitHub Actions workflows for CI and release (4ad266f7984742e7c5dd722340dc3c0786e4c7c9)
161
+ Adds a CI workflow that runs lint, type-check, tests with coverage, and
162
+ build across Node.js 20, 22, and 24 on every push and pull request to
163
+ main. Coverage is uploaded to Codecov from the Node 24 run only.
164
+
165
+ Adds a release workflow powered by semantic-release that triggers on
166
+ merges to main and fully automates versioning, changelog generation, npm
167
+ publish with provenance, and GitHub Release creation.
168
+
169
+ Adds a commit-msg git hook that enforces Conventional Commits format so
170
+ that semantic-release can reliably determine version bumps.
171
+
172
+ * add packageManager field for pnpm/action-setup (ee441628159346a66013bb429bf30e583d687b03)
173
+ * added missing test data (12d03ca176a8c4407610774e599325df7790e0bc)
174
+ * trigger actions (836151dd5d4e73e3bf51f2a6d5b11f462eef25a8)
175
+ * trigger actions (c415c4a08169fa103acbaaa9a1268485df6eb4e0)
176
+ * trigger actions (fc350c91e7e2546604361aade7f0f55530095b38)
177
+
178
+ ## [5.1.0](https://github.com/D1g1talEntr0py/media-type/compare/v5.0.0...v5.1.0) (2026-03-01)
179
+
180
+ ### Features
181
+
182
+ * convert to TypeScript (06901a60aa3d0643815e5f3c53d934f2dae0b361)
183
+
184
+ ### Code Refactoring
185
+
186
+ * **parser:** simplify component collection API (681e8f275b46cc39a6f146f1bcdddd85a277136a)
187
+ Replaces the options-object-based filterComponent method with a
188
+ straighter collect function returning a tuple, eliminating unnecessary
189
+ parameter grouping and making call sites easier to read.
190
+
191
+ Switches the whitespace character lookup from an array (O(n) includes)
192
+ to a Set (O(1) has) for a small but consistent performance gain.
193
+
194
+
195
+ ### Documentation
196
+
197
+ * update README badges and fix minor formatting (51cf9457fc604cccde032c060ecb86bf876a9713)
198
+ Replaces static badge URLs with dynamic ones that show live npm download
199
+ counts and the new CI/Codecov status badges, giving visitors an
200
+ immediate signal of project health.
201
+
202
+ Fixes trailing-whitespace and import-block formatting issues.
203
+
204
+
205
+ ### Miscellaneous Chores
206
+
207
+ * upgrade dev dependencies to latest versions (6b54d8b1cddf7dbc824dba54fd5933570b66a262)
208
+ Bumps eslint to v10, typescript-eslint to 8.56, vitest/coverage-v8/ui
209
+ to 4.0.18, @types/node to 25, @types/web to 0.0.338, and several
210
+ transitive deps (esbuild, rollup, vite, acorn, ajv, etc.).
211
+
212
+ Adds @d1g1tal/tsbuild as the project build tool, replacing the previous
213
+ build setup, and introduces a type-check script. Removes the duplicate
214
+ coverage script alias. Sets the minimum Node.js engine to >=20.16.0.
215
+
216
+ Updates .gitignore to track .tsbuild/ output directory.
217
+
218
+
219
+ ### Build System
220
+
221
+ * add semantic-release config and release docs (1cdaab0d9db81c363cf1d81e8ae36e758b2b7c57)
222
+ Adds a .releaserc.json that configures semantic-release with the
223
+ conventionalcommits preset, custom release rules (refactor triggers a
224
+ patch bump), grouped changelog sections, npm pack + publish with
225
+ provenance, and a git commit of CHANGELOG.md and package.json after
226
+ each release.
227
+
228
+ Adds a release-process.md guide explaining how to author commits,
229
+ open PRs, merge to main, and verify the automated release, including
230
+ a dry-run section and a troubleshooting FAQ.
231
+
232
+
233
+ ### Continuous Integration
234
+
235
+ * add GitHub Actions workflows for CI and release (4ad266f7984742e7c5dd722340dc3c0786e4c7c9)
236
+ Adds a CI workflow that runs lint, type-check, tests with coverage, and
237
+ build across Node.js 20, 22, and 24 on every push and pull request to
238
+ main. Coverage is uploaded to Codecov from the Node 24 run only.
239
+
240
+ Adds a release workflow powered by semantic-release that triggers on
241
+ merges to main and fully automates versioning, changelog generation, npm
242
+ publish with provenance, and GitHub Release creation.
243
+
244
+ Adds a commit-msg git hook that enforces Conventional Commits format so
245
+ that semantic-release can reliably determine version bumps.
246
+
247
+ * add packageManager field for pnpm/action-setup (ee441628159346a66013bb429bf30e583d687b03)
248
+ * trigger actions (836151dd5d4e73e3bf51f2a6d5b11f462eef25a8)
249
+ * trigger actions (c415c4a08169fa103acbaaa9a1268485df6eb4e0)
250
+ * trigger actions (fc350c91e7e2546604361aade7f0f55530095b38)
251
+
1
252
  # Changelog
2
253
 
3
254
  All notable changes to this project will be documented in this file.
package/LICENSE CHANGED
@@ -1,12 +1,15 @@
1
- Copyright (c) 2023, Jason DiMeo
1
+ ISC License
2
2
 
3
- Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided
4
- that the above copyright notice and this permission notice appear in all copies.
3
+ Copyright (c) 2023, Jason DiMeo
5
4
 
6
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
7
- INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE
8
- FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
9
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
10
- ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
11
8
 
12
- Source: http://opensource.org/licenses/ISC
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
package/README.md CHANGED
@@ -1,9 +1,12 @@
1
1
  # Parse, serialize, and manipulate media types
2
2
 
3
- [![npm version](https://img.shields.io/npm/v/@d1g1tal/media-type.svg)](https://www.npmjs.com/package/@d1g1tal/media-type)
4
- [![License: ISC](https://img.shields.io/badge/License-ISC-blue.svg)](https://opensource.org/licenses/ISC)
5
- [![TypeScript](https://img.shields.io/badge/TypeScript-5.9-blue.svg)](https://www.typescriptlang.org/)
6
- [![Node Version](https://img.shields.io/node/v/@d1g1tal/media-type.svg)](https://nodejs.org)
3
+ [![npm version](https://img.shields.io/npm/v/@d1g1tal/media-type?color=blue)](https://www.npmjs.com/package/@d1g1tal/media-type)
4
+ [![npm downloads](https://img.shields.io/npm/dm/@d1g1tal/media-type)](https://www.npmjs.com/package/@d1g1tal/media-type)
5
+ [![CI](https://github.com/D1g1talEntr0py/media-type/actions/workflows/ci.yml/badge.svg)](https://github.com/D1g1talEntr0py/media-type/actions/workflows/ci.yml)
6
+ [![codecov](https://codecov.io/gh/D1g1talEntr0py/media-type/graph/badge.svg)](https://codecov.io/gh/D1g1talEntr0py/media-type)
7
+ [![License: ISC](https://img.shields.io/github/license/D1g1talEntr0py/media-type?cacheSeconds=0)](https://github.com/D1g1talEntr0py/media-type/blob/main/LICENSE)
8
+ [![Node.js](https://img.shields.io/node/v/@d1g1tal/media-type)](https://nodejs.org)
9
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.9-blue?logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
7
10
 
8
11
  > **Note**: This is a TypeScript rewrite and fork of the original [`whatwg-mimetype`](https://github.com/jsdom/whatwg-mimetype) package. See [CHANGELOG.md](./CHANGELOG.md) for migration information.
9
12
 
@@ -151,12 +154,12 @@ In addition to the main `MediaType` class, this package also exports:
151
154
  - **Type exports**: `MediaTypeComponent`, `ParsedMediaType` (TypeScript types)
152
155
 
153
156
  ```typescript
154
- import {
155
- MediaType,
156
- MediaTypeParameters,
157
+ import {
158
+ MediaType,
159
+ MediaTypeParameters,
157
160
  MediaTypeParser,
158
161
  type MediaTypeComponent,
159
- type ParsedMediaType
162
+ type ParsedMediaType
160
163
  } from '@d1g1tal/media-type';
161
164
  ```
162
165
 
@@ -201,7 +204,7 @@ This project is a fork and substantial rewrite of the excellent [`whatwg-mimetyp
201
204
  - Optimize bundle size and performance
202
205
  - Maintain WHATWG standard compliance
203
206
 
204
- **Original Author**: Domenic Denicola
207
+ **Original Author**: Domenic Denicola
205
208
  **Current Maintainer**: Jason DiMeo
206
209
 
207
210
  The original contributors' excellent work is acknowledged with gratitude. This fork maintains the same commitment to WHATWG standards compliance while providing a modern TypeScript-first experience.
package/package.json CHANGED
@@ -1,80 +1,85 @@
1
1
  {
2
- "name": "@d1g1tal/media-type",
3
- "description": "Parses, serializes, and manipulates media types, according to the WHATWG MIME Sniffing Standard",
4
- "version": "6.0.0",
5
- "author": "Domenic Denicola <d@domenic.me> (https://domenic.me/)",
6
- "maintainers": [
7
- {
8
- "name": "Jason DiMeo",
9
- "email": "jason.dimeo@gmail.com"
10
- }
11
- ],
12
- "license": "ISC",
13
- "repository": {
14
- "type": "git",
15
- "url": "git+https://github.com/D1g1talEntr0py/media-type.git"
16
- },
17
- "bugs": {
18
- "url": "https://github.com/D1g1talEntr0py/media-type/issues"
19
- },
20
- "homepage": "https://github.com/D1g1talEntr0py/media-type#readme",
21
- "publishConfig": {
22
- "access": "public"
23
- },
24
- "type": "module",
25
- "exports": {
26
- ".": {
27
- "types": "./dist/media-type.d.ts",
28
- "import": "./dist/media-type.js"
29
- }
30
- },
31
- "files": [
32
- "/dist",
33
- "README.md",
34
- "LICENSE",
35
- "CHANGELOG.md"
36
- ],
37
- "keywords": [
38
- "content-type",
39
- "mime type",
40
- "media type",
41
- "mimesniff",
42
- "mime",
43
- "http",
44
- "whatwg",
45
- "typescript",
46
- "esm",
47
- "parser",
48
- "serializer"
49
- ],
50
- "devDependencies": {
51
- "@eslint/js": "^9.39.0",
52
- "@types/node": "^24.9.2",
53
- "@typescript-eslint/eslint-plugin": "^8.46.2",
54
- "@typescript-eslint/parser": "^8.46.2",
55
- "@typescript/lib-dom": "npm:@types/web@^0.0.288",
56
- "@vitest/coverage-v8": "4.0.6",
57
- "@vitest/ui": "^4.0.6",
58
- "eslint": "^9.39.0",
59
- "eslint-plugin-jsdoc": "^61.1.11",
60
- "printable-string": "^0.3.0",
61
- "typescript": "^5.9.3",
62
- "typescript-eslint": "^8.46.2",
63
- "vitest": "^4.0.6",
64
- "whatwg-encoding": "^3.1.1"
65
- },
66
- "browserslist": [
67
- "defaults and fully supports es6-module",
68
- "maintained node versions"
69
- ],
70
- "scripts": {
71
- "build": "tsbuild",
72
- "test": "vitest run",
73
- "test:watch": "vitest",
74
- "test:ui": "vitest run --ui",
75
- "test:coverage": "vitest run --coverage",
76
- "lint": "eslint",
77
- "coverage": "vitest run --coverage",
78
- "pretest": "node tests/scripts/get-latest-platform-tests.ts"
79
- }
80
- }
2
+ "name": "@d1g1tal/media-type",
3
+ "description": "Parses, serializes, and manipulates media types, according to the WHATWG MIME Sniffing Standard",
4
+ "version": "6.0.2",
5
+ "author": "Domenic Denicola <d@domenic.me> (https://domenic.me/)",
6
+ "maintainers": [
7
+ {
8
+ "name": "Jason DiMeo",
9
+ "email": "jason.dimeo@gmail.com"
10
+ }
11
+ ],
12
+ "license": "ISC",
13
+ "packageManager": "pnpm@10.30.3",
14
+ "engines": {
15
+ "node": ">=20.16.0"
16
+ },
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/D1g1talEntr0py/media-type.git"
20
+ },
21
+ "bugs": {
22
+ "url": "https://github.com/D1g1talEntr0py/media-type/issues"
23
+ },
24
+ "homepage": "https://github.com/D1g1talEntr0py/media-type#readme",
25
+ "publishConfig": {
26
+ "access": "public"
27
+ },
28
+ "type": "module",
29
+ "exports": {
30
+ ".": {
31
+ "types": "./dist/media-type.d.ts",
32
+ "import": "./dist/media-type.js"
33
+ }
34
+ },
35
+ "files": [
36
+ "/dist",
37
+ "README.md",
38
+ "LICENSE",
39
+ "CHANGELOG.md"
40
+ ],
41
+ "keywords": [
42
+ "content-type",
43
+ "mime type",
44
+ "media type",
45
+ "mimesniff",
46
+ "mime",
47
+ "http",
48
+ "whatwg",
49
+ "typescript",
50
+ "esm",
51
+ "parser",
52
+ "serializer"
53
+ ],
54
+ "scripts": {
55
+ "build": "tsbuild",
56
+ "type-check": "tsbuild --noEmit",
57
+ "test": "vitest run",
58
+ "test:watch": "vitest",
59
+ "test:ui": "vitest run --ui",
60
+ "test:coverage": "vitest run --coverage",
61
+ "lint": "eslint",
62
+ "pretest": "node tests/scripts/get-latest-platform-tests.ts"
63
+ },
64
+ "devDependencies": {
65
+ "@d1g1tal/tsbuild": "^1.3.2",
66
+ "@eslint/js": "^10.0.1",
67
+ "@types/node": "^25.3.3",
68
+ "@typescript-eslint/eslint-plugin": "^8.56.1",
69
+ "@typescript-eslint/parser": "^8.56.1",
70
+ "@typescript/lib-dom": "npm:@types/web@^0.0.339",
71
+ "@vitest/coverage-v8": "4.0.18",
72
+ "@vitest/ui": "^4.0.18",
73
+ "eslint": "^10.0.2",
74
+ "eslint-plugin-jsdoc": "^62.7.1",
75
+ "printable-string": "^0.3.0",
76
+ "typescript": "^5.9.3",
77
+ "typescript-eslint": "^8.56.1",
78
+ "vitest": "^4.0.18",
79
+ "whatwg-encoding": "^3.1.1"
80
+ },
81
+ "browserslist": [
82
+ "defaults and fully supports es6-module",
83
+ "maintained node versions"
84
+ ]
85
+ }
@@ -1,184 +0,0 @@
1
- /**
2
- * Class representing the parameters for a media type record.
3
- * This class extends a JavaScript Map<string, string>.
4
- *
5
- * However, MediaTypeParameters methods will always interpret their arguments
6
- * as appropriate for media types, so parameter names will be lowercased,
7
- * and attempting to set invalid characters will throw an Error.
8
- *
9
- * @see https://mimesniff.spec.whatwg.org
10
- * @author D1g1talEntr0py <jason.dimeo@gmail.com>
11
- */
12
- declare class MediaTypeParameters extends Map<string, string> {
13
- /**
14
- * Create a new MediaTypeParameters instance.
15
- *
16
- * @param entries An array of [ name, value ] tuples.
17
- */
18
- constructor(entries?: Iterable<[string, string]>);
19
- /**
20
- * Indicates whether the supplied name and value are valid media type parameters.
21
- *
22
- * @param name The name of the media type parameter to validate.
23
- * @param value The media type parameter value to validate.
24
- * @returns true if the media type parameter is valid, false otherwise.
25
- */
26
- static isValid(name: string, value: string): boolean;
27
- /**
28
- * Gets the media type parameter value for the supplied name.
29
- *
30
- * @param name The name of the media type parameter to retrieve.
31
- * @returns The media type parameter value.
32
- */
33
- get(name: string): string | undefined;
34
- /**
35
- * Indicates whether the media type parameter with the specified name exists or not.
36
- *
37
- * @param name The name of the media type parameter to check.
38
- * @returns true if the media type parameter exists, false otherwise.
39
- */
40
- has(name: string): boolean;
41
- /**
42
- * Adds a new media type parameter using the specified name and value to the MediaTypeParameters.
43
- * If an parameter with the same name already exists, the parameter will be updated.
44
- *
45
- * @param name The name of the media type parameter to set.
46
- * @param value The media type parameter value.
47
- * @returns This instance.
48
- */
49
- set(name: string, value: string): this;
50
- /**
51
- * Removes the media type parameter using the specified name.
52
- *
53
- * @param name The name of the media type parameter to delete.
54
- * @returns true if the parameter existed and has been removed, or false if the parameter does not exist.
55
- */
56
- delete(name: string): boolean;
57
- /**
58
- * Returns a string representation of the media type parameters.
59
- *
60
- * @returns The string representation of the media type parameters.
61
- */
62
- toString(): string;
63
- /**
64
- * Returns the name of this class.
65
- *
66
- * @returns The name of this class.
67
- */
68
- get [Symbol.toStringTag](): string;
69
- }
70
-
71
- /**
72
- * Class used to parse media types.
73
- * @see https://mimesniff.spec.whatwg.org/#understanding-mime-types
74
- */
75
- declare class MediaType {
76
- private readonly _type;
77
- private readonly _subtype;
78
- private readonly _parameters;
79
- /**
80
- * Create a new MediaType instance from a string representation.
81
- * @param mediaType The media type to parse.
82
- * @param parameters Optional parameters.
83
- */
84
- constructor(mediaType: string, parameters?: Record<string, string>);
85
- /**
86
- * Parses a media type string.
87
- * @param mediaType The media type to parse.
88
- * @returns The parsed media type or null if the mediaType cannot be parsed.
89
- */
90
- static parse(mediaType: string): MediaType | null;
91
- /**
92
- * Gets the type.
93
- * @returns The type.
94
- */
95
- get type(): string;
96
- /**
97
- * Gets the subtype.
98
- * @returns The subtype.
99
- */
100
- get subtype(): string;
101
- /**
102
- * Gets the media type essence (type/subtype).
103
- * @returns The media type without any parameters
104
- */
105
- get essence(): string;
106
- /**
107
- * Gets the parameters.
108
- * @returns The media type parameters.
109
- */
110
- get parameters(): MediaTypeParameters;
111
- /**
112
- * Checks if the media type matches the specified type.
113
- *
114
- * @param mediaType The media type to check.
115
- * @returns true if the media type matches the specified type, false otherwise.
116
- */
117
- matches(mediaType: MediaType | string): boolean;
118
- /**
119
- * Gets the serialized version of the media type.
120
- *
121
- * @returns The serialized media type.
122
- */
123
- toString(): string;
124
- /**
125
- * Gets the name of the class.
126
- * @returns The class name
127
- */
128
- get [Symbol.toStringTag](): string;
129
- }
130
-
131
- interface MediaTypeComponent {
132
- position?: number;
133
- input: string;
134
- lowerCase?: boolean;
135
- trim?: boolean;
136
- }
137
- interface ParsedMediaType {
138
- type: string;
139
- subtype: string;
140
- parameters: MediaTypeParameters;
141
- }
142
- /**
143
- * Parser for media types.
144
- * @see https://mimesniff.spec.whatwg.org/#parsing-a-mime-type
145
- * @author D1g1talEntr0py <jason.dimeo@gmail.com>
146
- */
147
- declare class MediaTypeParser {
148
- /**
149
- * Function to parse a media type.
150
- * @param input The media type to parse
151
- * @returns An object populated with the parsed media type properties and any parameters.
152
- */
153
- static parse(input: string): ParsedMediaType;
154
- /**
155
- * Gets the name of this class.
156
- * @returns The string tag of this class.
157
- */
158
- get [Symbol.toStringTag](): string;
159
- /**
160
- * Filters a component from the input string.
161
- * @param options The options.
162
- * @param charactersToFilter The characters to filter.
163
- * @returns An object that includes the resulting string and updated position.
164
- */
165
- private static filterComponent;
166
- /**
167
- * Collects all the HTTP quoted strings.
168
- * This variant only implements it with the extract-value flag set.
169
- * @param input The string to process.
170
- * @param position The starting position.
171
- * @returns An array that includes the resulting string and updated position.
172
- */
173
- private static collectHttpQuotedString;
174
- /**
175
- * Generates an error message.
176
- * @param component The component name.
177
- * @param value The component value.
178
- * @returns The error message.
179
- */
180
- private static generateErrorMessage;
181
- }
182
-
183
- export { MediaType, MediaTypeParameters, MediaTypeParser };
184
- export type { MediaTypeComponent, ParsedMediaType };
@@ -1,283 +0,0 @@
1
- // src/utils.ts
2
- var httpTokenCodePoints = /^[-!#$%&'*+.^_`|~A-Za-z0-9]*$/u;
3
-
4
- // src/media-type-parameters.ts
5
- var matcher = /(["\\])/ug;
6
- var httpQuotedStringTokenCodePoints = /^[\t\u0020-\u007E\u0080-\u00FF]*$/u;
7
- var MediaTypeParameters = class _MediaTypeParameters extends Map {
8
- /**
9
- * Create a new MediaTypeParameters instance.
10
- *
11
- * @param entries An array of [ name, value ] tuples.
12
- */
13
- constructor(entries = []) {
14
- super(entries);
15
- }
16
- /**
17
- * Indicates whether the supplied name and value are valid media type parameters.
18
- *
19
- * @param name The name of the media type parameter to validate.
20
- * @param value The media type parameter value to validate.
21
- * @returns true if the media type parameter is valid, false otherwise.
22
- */
23
- static isValid(name, value) {
24
- return httpTokenCodePoints.test(name) && httpQuotedStringTokenCodePoints.test(value);
25
- }
26
- /**
27
- * Gets the media type parameter value for the supplied name.
28
- *
29
- * @param name The name of the media type parameter to retrieve.
30
- * @returns The media type parameter value.
31
- */
32
- get(name) {
33
- return super.get(name.toLowerCase());
34
- }
35
- /**
36
- * Indicates whether the media type parameter with the specified name exists or not.
37
- *
38
- * @param name The name of the media type parameter to check.
39
- * @returns true if the media type parameter exists, false otherwise.
40
- */
41
- has(name) {
42
- return super.has(name.toLowerCase());
43
- }
44
- /**
45
- * Adds a new media type parameter using the specified name and value to the MediaTypeParameters.
46
- * If an parameter with the same name already exists, the parameter will be updated.
47
- *
48
- * @param name The name of the media type parameter to set.
49
- * @param value The media type parameter value.
50
- * @returns This instance.
51
- */
52
- set(name, value) {
53
- if (!_MediaTypeParameters.isValid(name, value)) {
54
- throw new Error(`Invalid media type parameter name/value: ${name}/${value}`);
55
- }
56
- super.set(name.toLowerCase(), value);
57
- return this;
58
- }
59
- /**
60
- * Removes the media type parameter using the specified name.
61
- *
62
- * @param name The name of the media type parameter to delete.
63
- * @returns true if the parameter existed and has been removed, or false if the parameter does not exist.
64
- */
65
- delete(name) {
66
- return super.delete(name.toLowerCase());
67
- }
68
- /**
69
- * Returns a string representation of the media type parameters.
70
- *
71
- * @returns The string representation of the media type parameters.
72
- */
73
- toString() {
74
- return Array.from(this).map(([name, value]) => `;${name}=${!value || !httpTokenCodePoints.test(value) ? `"${value.replace(matcher, "\\$1")}"` : value}`).join("");
75
- }
76
- /**
77
- * Returns the name of this class.
78
- *
79
- * @returns The name of this class.
80
- */
81
- get [Symbol.toStringTag]() {
82
- return "MediaTypeParameters";
83
- }
84
- };
85
-
86
- // src/media-type-parser.ts
87
- var whitespaceCharacters = [" ", " ", "\n", "\r"];
88
- var trailingWhitespace = /[ \t\n\r]+$/u;
89
- var leadingAndTrailingWhitespace = /^[ \t\n\r]+|[ \t\n\r]+$/ug;
90
- var MediaTypeParser = class _MediaTypeParser {
91
- /**
92
- * Function to parse a media type.
93
- * @param input The media type to parse
94
- * @returns An object populated with the parsed media type properties and any parameters.
95
- */
96
- static parse(input) {
97
- input = input.replace(leadingAndTrailingWhitespace, "");
98
- const length = input.length, trim = true, lowerCase = false;
99
- const { position: initialPosition, result: type } = _MediaTypeParser.filterComponent({ input }, "/");
100
- let position = initialPosition;
101
- if (!type.length || position >= length || !httpTokenCodePoints.test(type)) {
102
- throw new TypeError(_MediaTypeParser.generateErrorMessage("type", type));
103
- }
104
- let subtype = "";
105
- ({ position, result: subtype } = _MediaTypeParser.filterComponent({ position: ++position, input, trim }, ";"));
106
- if (!subtype.length || !httpTokenCodePoints.test(subtype)) {
107
- throw new TypeError(_MediaTypeParser.generateErrorMessage("subtype", subtype));
108
- }
109
- let parameterName = "";
110
- let parameterValue = null;
111
- const parameters = new MediaTypeParameters();
112
- while (position++ < length) {
113
- while (whitespaceCharacters.includes(input[position])) {
114
- ++position;
115
- }
116
- ({ position, result: parameterName } = _MediaTypeParser.filterComponent({ position, input, lowerCase }, ";", "="));
117
- if (position < length) {
118
- if (input[position] == ";") {
119
- continue;
120
- }
121
- ++position;
122
- }
123
- if (input[position] === '"') {
124
- [parameterValue, position] = _MediaTypeParser.collectHttpQuotedString(input, position);
125
- while (position < length && input[position] !== ";") {
126
- ++position;
127
- }
128
- } else {
129
- ({ position, result: parameterValue } = _MediaTypeParser.filterComponent({ position, input, lowerCase, trim }, ";"));
130
- if (!parameterValue) {
131
- continue;
132
- }
133
- }
134
- if (parameterName && parameterValue !== null && MediaTypeParameters.isValid(parameterName, parameterValue) && !parameters.has(parameterName)) {
135
- parameters.set(parameterName, parameterValue);
136
- }
137
- }
138
- return { type, subtype, parameters };
139
- }
140
- /**
141
- * Gets the name of this class.
142
- * @returns The string tag of this class.
143
- */
144
- get [Symbol.toStringTag]() {
145
- return "MediaTypeParser";
146
- }
147
- /**
148
- * Filters a component from the input string.
149
- * @param options The options.
150
- * @param charactersToFilter The characters to filter.
151
- * @returns An object that includes the resulting string and updated position.
152
- */
153
- static filterComponent({ position = 0, input, lowerCase = true, trim = false }, ...charactersToFilter) {
154
- let result = "";
155
- for (const length = input.length; position < length && !charactersToFilter.includes(input[position]); position++) {
156
- result += input[position];
157
- }
158
- if (lowerCase) {
159
- result = result.toLowerCase();
160
- }
161
- if (trim) {
162
- result = result.replace(trailingWhitespace, "");
163
- }
164
- return { position, result };
165
- }
166
- /**
167
- * Collects all the HTTP quoted strings.
168
- * This variant only implements it with the extract-value flag set.
169
- * @param input The string to process.
170
- * @param position The starting position.
171
- * @returns An array that includes the resulting string and updated position.
172
- */
173
- static collectHttpQuotedString(input, position) {
174
- let value = "";
175
- for (let length = input.length, char; ++position < length; ) {
176
- if ((char = input[position]) === '"') {
177
- break;
178
- }
179
- value += char == "\\" && ++position < length ? input[position] : char;
180
- }
181
- return [value, position];
182
- }
183
- /**
184
- * Generates an error message.
185
- * @param component The component name.
186
- * @param value The component value.
187
- * @returns The error message.
188
- */
189
- static generateErrorMessage(component, value) {
190
- return `Invalid ${component} "${value}": only HTTP token code points are valid.`;
191
- }
192
- };
193
-
194
- // src/media-type.ts
195
- var MediaType = class _MediaType {
196
- _type;
197
- _subtype;
198
- _parameters;
199
- /**
200
- * Create a new MediaType instance from a string representation.
201
- * @param mediaType The media type to parse.
202
- * @param parameters Optional parameters.
203
- */
204
- constructor(mediaType, parameters = {}) {
205
- if (parameters === null || typeof parameters !== "object" || Array.isArray(parameters)) {
206
- throw new TypeError("The parameters argument must be an object");
207
- }
208
- ({ type: this._type, subtype: this._subtype, parameters: this._parameters } = MediaTypeParser.parse(mediaType));
209
- for (const [name, value] of Object.entries(parameters)) {
210
- this._parameters.set(name, value);
211
- }
212
- }
213
- /**
214
- * Parses a media type string.
215
- * @param mediaType The media type to parse.
216
- * @returns The parsed media type or null if the mediaType cannot be parsed.
217
- */
218
- static parse(mediaType) {
219
- try {
220
- return new _MediaType(mediaType);
221
- } catch {
222
- }
223
- return null;
224
- }
225
- /**
226
- * Gets the type.
227
- * @returns The type.
228
- */
229
- get type() {
230
- return this._type;
231
- }
232
- /**
233
- * Gets the subtype.
234
- * @returns The subtype.
235
- */
236
- get subtype() {
237
- return this._subtype;
238
- }
239
- /**
240
- * Gets the media type essence (type/subtype).
241
- * @returns The media type without any parameters
242
- */
243
- get essence() {
244
- return `${this._type}/${this._subtype}`;
245
- }
246
- /**
247
- * Gets the parameters.
248
- * @returns The media type parameters.
249
- */
250
- get parameters() {
251
- return this._parameters;
252
- }
253
- /**
254
- * Checks if the media type matches the specified type.
255
- *
256
- * @param mediaType The media type to check.
257
- * @returns true if the media type matches the specified type, false otherwise.
258
- */
259
- matches(mediaType) {
260
- return typeof mediaType === "string" ? this.essence.includes(mediaType) : this._type === mediaType._type && this._subtype === mediaType._subtype;
261
- }
262
- /**
263
- * Gets the serialized version of the media type.
264
- *
265
- * @returns The serialized media type.
266
- */
267
- toString() {
268
- return `${this.essence}${this._parameters.toString()}`;
269
- }
270
- /**
271
- * Gets the name of the class.
272
- * @returns The class name
273
- */
274
- get [Symbol.toStringTag]() {
275
- return "MediaType";
276
- }
277
- };
278
- export {
279
- MediaType,
280
- MediaTypeParameters,
281
- MediaTypeParser
282
- };
283
- //# sourceMappingURL=media-type.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 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 whitespaceCharacters: string[] = [' ', '\\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\tconst length = input.length, trim = true, lowerCase = false;\n\t\tconst { position: initialPosition, result: type } = MediaTypeParser.filterComponent({ input }, '/');\n\t\tlet position = initialPosition;\n\n\t\tif (!type.length || position >= length || !httpTokenCodePoints.test(type)) {\n\t\t\tthrow new TypeError(MediaTypeParser.generateErrorMessage('type', type));\n\t\t}\n\n\t\tlet subtype = '';\n\t\t({ position, result: subtype } = MediaTypeParser.filterComponent({ position: ++position, input, trim }, ';')); // `++position` Skips past \"/\"\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\tlet parameterName = '';\n\t\tlet parameterValue: string | null = null;\n\t\tconst parameters = new MediaTypeParameters();\n\n\t\twhile (position++ < length) { // `position++` Skips past \"/\"\n\t\t\twhile (whitespaceCharacters.includes(input[position]!)) { ++position }\n\n\t\t\t({ position, result: parameterName } = MediaTypeParser.filterComponent({ position, input, lowerCase }, ';', '='));\n\n\t\t\tif (position < length) {\n\t\t\t\tif (input[position] == ';') { continue }\n\n\t\t\t\t// Skip past \"=\"\n\t\t\t\t++position;\n\t\t\t}\n\n\t\t\tif (input[position] === '\"') {\n\t\t\t\t[ parameterValue, position ] = MediaTypeParser.collectHttpQuotedString(input, position);\n\n\t\t\t\twhile (position < length && input[position] !== ';') { ++position }\n\t\t\t} else {\n\t\t\t\t({ position, result: parameterValue } = MediaTypeParser.filterComponent({ position, input, lowerCase, trim }, ';'));\n\n\t\t\t\tif (!parameterValue) { continue }\n\t\t\t}\n\n\t\t\tif (parameterName && parameterValue !== null && MediaTypeParameters.isValid(parameterName, parameterValue) && !parameters.has(parameterName)) {\n\t\t\t\tparameters.set(parameterName, parameterValue);\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 * Filters a component from the input string.\n\t * @param options The options.\n\t * @param charactersToFilter The characters to filter.\n\t * @returns An object that includes the resulting string and updated position.\n\t */\n\tprivate static filterComponent({ position = 0, input, lowerCase = true, trim = false }: MediaTypeComponent, ...charactersToFilter: string[]): { position: number, result: string } {\n\t\tlet result = '';\n\t\tfor (const length = input.length; position < length && !charactersToFilter.includes(input[position]!); position++) {\n\t\t\tresult += input[position];\n\t\t}\n\n\t\tif (lowerCase) { result = result.toLowerCase() }\n\t\tif (trim) { result = result.replace(trailingWhitespace, '') }\n\n\t\treturn { position, result };\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,IAAM,sBAA8B;;;ACE3C,IAAM,UAAkB;AACxB,IAAM,kCAA0C;AAazC,IAAM,sBAAN,MAAM,6BAA4B,IAAoB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAM5D,YAAY,UAAsC,CAAC,GAAG;AACrD,UAAM,OAAO;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,OAAO,QAAQ,MAAc,OAAwB;AACpD,WAAO,oBAAoB,KAAK,I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