-
-
Notifications
You must be signed in to change notification settings - Fork 39
feat: Add CaseInsensitiveSet with original casing support
#576
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: Add CaseInsensitiveSet with original casing support
#576
Conversation
- Adds a custom `Set`-like class `CaseInsensitiveSet` that performs case-insensitive string operations. - Internally uses a `Map<string, T>` to store normalized keys and preserve the first-in original casing. - Implements standard methods: `add`, `delete`, `has`, `clear`, `forEach`, `entries`, `keys`, `values`, and `[Symbol.iterator]`. - Supports method chaining and uses locale-aware normalization via `toLocaleLowerCase()`.
- Covers construction with default and custom iterables, including case deduplication. - Verifies core methods: `add`, `delete`, `has`, `clear`, `forEach`, `values`, `keys`, `entries`, and iteration support. - Ensures case-insensitive logic works across registries, scripts, Unicode, and large strings. - Adds tests for real-world usage patterns including CLI simulation and integration scenarios. - Validates original casing preservation and locale-aware behavior.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Introduces a CaseInsensitiveSet to handle string deduplication in a case-insensitive manner—preserving the casing of the first occurrence—and swaps it in place of native Set in repo init/add commands.
- Adds a
CaseInsensitiveSetimplementation with full Set-like API and locale-aware normalization - Updates
initandaddcommands to replaceSetwithCaseInsensitiveSetfor repository lists - Adds a comprehensive Vitest suite covering functionality, edge cases, performance, and CLI integration
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tests/case-insensitive-set.test.ts | New test suite validating all operations, edge cases, and CLI use |
| src/utils/case-insensitive-set.ts | New CaseInsensitiveSet class using a Map for case-insensitive storage |
| src/commands/init.ts | Replaces native Set with CaseInsensitiveSet in initialization |
| src/commands/add.ts | Replaces native Set with CaseInsensitiveSet in add command |
Comments suppressed due to low confidence (1)
src/utils/case-insensitive-set.ts:81
- [nitpick] The second parameter
_value2inforEachis unused and may confuse readers; consider renaming it to_keyor omitting the underscore prefix to better reflect its purpose in a Set callback.
callbackfn: (value: T, _value2: T, set: CaseInsensitiveSet<T>) => void,
CaseInsensitiveSetclass using aMapfor case-insensitive operations.add,delete,has,clear,forEach,entries,keys,values, and iteration.toLocaleLowerCase().Replaces
SetwithCaseInsensitiveSetininitandadd.Closes #515