Add getItemValues to exported members#168
Conversation
WalkthroughThe Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Tip 📝 Customizable high-level summaries are now available in beta!You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
Example instruction:
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| } | ||
|
|
||
| export {matchSorter, rankings, defaultBaseSortFn} | ||
| export {matchSorter, rankings, defaultBaseSortFn, getItemValues} |
There was a problem hiding this comment.
🧩 Analysis chain
LGTM! Export addition enables custom implementations.
The getItemValues function is now accessible for external use, supporting custom matching behaviors as described in the PR objectives. The function is well-typed, documented, and already battle-tested through internal usage.
Please verify the following to ensure a smooth public API launch:
-
Test coverage: Confirm that tests exist covering the various code paths in
getItemValues(object keys, functions, nested paths, wildcards, null handling, arrays). If integration tests for the new export don't exist, consider adding examples that demonstrate its public usage. -
Documentation: Consider updating the README or adding usage examples showing how external consumers can leverage
getItemValuesfor custom implementations. The current JSDoc describes the function signature but may not provide enough context for users implementing custom match modes. -
API stability: Confirm that the function signature and behavior are stable for long-term public use, as changes will now be breaking changes for consumers.
🏁 Script executed:
#!/bin/bash
# Verify test coverage for getItemValues function
echo "Searching for tests covering getItemValues..."
rg -n "getItemValues" --type=ts --type=js -g "*test*" -g "*spec*"
echo -e "\nSearching for existing documentation or examples..."
rg -n "getItemValues" README.md docs/ -g "*.md" 2>/dev/null || echo "No markdown documentation found"Length of output: 279
I'll run more targeted searches to verify the test coverage and documentation status:
---
🏁 Script executed:
```shell
#!/bin/bash
# Find test files more broadly
echo "Looking for test/spec files in the repository..."
fd -e test -e spec -e ".test.ts" -e ".spec.ts" -e ".test.js" -e ".spec.js" | head -20
echo -e "\nSearching for getItemValues in all TypeScript/JavaScript files..."
rg "getItemValues" -n --type=ts --type=js -B2 -A2 | head -50
echo -e "\nChecking README for export documentation..."
head -100 README.md
echo -e "\nChecking package.json exports field..."
cat package.json | grep -A 20 '"exports"' || echo "No exports field in package.json"
Length of output: 1108
🏁 Script executed:
#!/bin/bash
# Search repository properly with cloning enabled
echo "Finding all test-related files..."
find . -type f \( -name "*.test.ts" -o -name "*.spec.ts" -o -name "*.test.js" -o -name "*.spec.js" \) 2>/dev/null | head -20
echo -e "\nSearching for getItemValues references in entire repository..."
rg "getItemValues" -n -B1 -A1 2>/dev/null | head -80
echo -e "\nChecking for README files..."
find . -maxdepth 2 -type f -iname "readme*" 2>/dev/null
echo -e "\nChecking for test configuration (jest, vitest, etc)..."
find . -maxdepth 2 -type f \( -name "jest.config.*" -o -name "vitest.config.*" -o -name ".test.js" \) 2>/dev/null
echo -e "\nSearching in src directory for test files..."
find ./src -type f -name "*test*" -o -name "*spec*" 2>/dev/nullLength of output: 673
🏁 Script executed:
#!/bin/bash
# Read README to understand current documentation
echo "=== README.md Content ==="
cat README.md
echo -e "\n\n=== package.json Content ==="
cat package.json
echo -e "\n\n=== Looking for test directories and scripts ==="
find . -type d -name test -o -name tests -o -name __tests__ 2>/dev/null
ls -la | grep -E "test|spec"Length of output: 31308
🏁 Script executed:
#!/bin/bash
# Examine test directory structure and check for getItemValues coverage
echo "=== Contents of src/__tests__/ ==="
find ./src/__tests__ -type f | head -20
echo -e "\n=== Searching for getItemValues in test files ==="
rg "getItemValues" ./src/__tests__ -n -B2 -A2
echo -e "\n=== Checking test file naming and count ==="
find ./src/__tests__ -type f -name "*.ts" -o -name "*.js" | wc -l
echo -e "\n=== Sample test file structure ==="
ls -la ./src/__tests__/ | head -20
echo -e "\n=== Checking if getAllValuesToRank (internal user) is tested ==="
rg "getAllValuesToRank" ./src/__tests__ -n -lLength of output: 432
🏁 Script executed:
#!/bin/bash
# Read the test file to understand coverage approach
echo "=== Test file content (first 150 lines) ==="
head -150 ./src/__tests__/index.ts
echo -e "\n\n=== Search for test patterns that might exercise getItemValues ==="
grep -n "keys.*\[" ./src/__tests__/index.ts | head -20
echo -e "\n\n=== Looking for nested path tests (which uses getItemValues) ==="
grep -n "name.first\|nested\|\." ./src/__tests__/index.ts | head -20
echo -e "\n\n=== Total lines in test file ==="
wc -l ./src/__tests__/index.tsLength of output: 6886
Update review comment with verification results—documentation updates still recommended.
Verification confirms comprehensive test coverage through integration tests exercising all code paths in getItemValues (object keys, nested paths with dot notation, wildcards, array indices, null handling, and function callbacks). The function is called internally by getAllValuesToRank in every test using the keys option, providing strong indirect coverage.
However, the README does not currently document getItemValues as a public export. Consider adding a section documenting its signature and usage examples for consumers implementing custom match modes, complementing the existing keys option documentation.
🤖 Prompt for AI Agents
In src/index.ts around line 523, the review notes that getItemValues is exported
but not documented; add a new section to the README that declares getItemValues
as a public export, documents its function signature (params and return type),
describes supported behaviors (object keys, dot-paths, wildcards, array indices,
null handling, callback usage), shows 2–3 concise usage examples (including one
showing how to implement a custom match mode using getItemValues and one
demonstrating integration with the existing keys option), and add a short note
linking from the existing keys documentation to this new section so consumers
can find it.
|
🎉 This PR is included in version 8.2.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
What:
Expose
getItemValuesWhy:
useful to implement custom behavior while reusing the "keys" syntax for different data-types
Usecase: allow a new match mode - see #167
How:
just added
getItemValuesto exported members - no fancy cahnges.Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.