Skip to content

Add getItemValues to exported members#168

Merged
kentcdodds merged 1 commit into
kentcdodds:mainfrom
IARI:expose-getitemvalues
Nov 24, 2025
Merged

Add getItemValues to exported members#168
kentcdodds merged 1 commit into
kentcdodds:mainfrom
IARI:expose-getitemvalues

Conversation

@IARI

@IARI IARI commented Nov 21, 2025

Copy link
Copy Markdown
Contributor

What:
Expose getItemValues

Why:
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 getItemValues to exported members - no fancy cahnges.

Summary by CodeRabbit

  • New Features
    • Public API expanded to include new functionality for accessing and retrieving item values.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Nov 21, 2025

Copy link
Copy Markdown

Walkthrough

The getItemValues function is exported from the public API via src/index.ts. Previously internal, the function is now accessible to consumers of this module without changes to its implementation.

Changes

Cohort / File(s) Change Summary
Public API Expansion
src/index.ts
Exports previously internal getItemValues function as part of the public module API

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

  • Single-line change: adding a function name to an export statement
  • No logic modifications, implementation changes, or control flow alterations
  • Straightforward visibility change with minimal risk surface

Poem

🐰 A function once hidden away,
Now shines in the light of the day!
getItemValues is free,
For all users to see,
Our API's expanded to play! ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add getItemValues to exported members' directly and accurately summarizes the main change in the pull request.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 65e774a and 95acfe8.

📒 Files selected for processing (1)
  • src/index.ts (1 hunks)

Comment thread src/index.ts
}

export {matchSorter, rankings, defaultBaseSortFn}
export {matchSorter, rankings, defaultBaseSortFn, getItemValues}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 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:

  1. 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.

  2. Documentation: Consider updating the README or adding usage examples showing how external consumers can leverage getItemValues for custom implementations. The current JSDoc describes the function signature but may not provide enough context for users implementing custom match modes.

  3. 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/null

Length 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 -l

Length 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.ts

Length 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.

@kentcdodds kentcdodds left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thanks!

@kentcdodds kentcdodds merged commit 6be7acb into kentcdodds:main Nov 24, 2025
5 checks passed
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 8.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants