Commit 8c981e0
refactor(accepts): inline negotiator dependency (#479)
* refactor(accepts): inline negotiator dependency
- Add packages/accepts/src/negotiator.ts with full TypeScript implementation
- Remove negotiator and @types/negotiator dependencies
- Add comprehensive test suite (44 tests) for negotiator functionality
- Reduces external dependencies by 2 packages
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* refactor(accepts): use # for private fields
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* refactor(accepts): remove unused BaseSpec interface
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* refactor(accepts): deduplicate compare functions
Replace 4 identical compareXxxSpecs functions with single compareByQI.
525 → 513 lines.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* refactor(accepts): modernize negotiator.ts with ES2022+ features
- Use flatMap instead of for loops with push for parse functions
- Use find for q-value extraction instead of for loops
- Use reduce for priority calculation functions
- Use template literals for string concatenation
- Use regex match for quoteCount function
- Use ternary expressions where cleaner
Reduces file from 513 to 430 lines (~16% reduction)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* style(accepts): apply Biome formatting
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* chore: add changeset for inlined negotiator
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix(accepts): fix split functions and improve test coverage
- Fix splitMediaTypes to truncate array after merging quoted sections
- Fix splitParameters similarly
- Add test for mismatched media type parameters
- Add test for comma inside quoted parameter
- Add test for semicolon inside quoted parameter
Achieves 100% line coverage for negotiator.ts
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* test(accepts): add more tests for full coverage
- Add array header tests for charsets, encodings, languages
- Add malformed input tests for charsets and languages
- Add invalid provided format tests for languages and mediaTypes
- Add wildcard parameter value test for mediaTypes
- Add parameter without value test
- Add minQuality test for implicit identity encoding
Now at 57 tests with 100% line coverage
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>1 parent c31446a commit 8c981e0
6 files changed
Lines changed: 765 additions & 24 deletions
File tree
- .changeset
- packages/accepts
- src
- tests/modules
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | 25 | | |
29 | | - | |
30 | | - | |
| 26 | + | |
31 | 27 | | |
32 | 28 | | |
33 | 29 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
0 commit comments