Skip to content

feat: add std::string_view overload for Symbol::For#1722

Merged
legendecas merged 3 commits intonodejs:mainfrom
umuoy1:feat/symbol-for-string-view
Apr 15, 2026
Merged

feat: add std::string_view overload for Symbol::For#1722
legendecas merged 3 commits intonodejs:mainfrom
umuoy1:feat/symbol-for-string-view

Conversation

@umuoy1
Copy link
Copy Markdown
Contributor

@umuoy1 umuoy1 commented Apr 10, 2026

Symbol::For had overloads for const std::string&, const char*, String, and napi_value, but was missing a std::string_view overload. This made it inconsistent with other APIs like String::New which already accept std::string_view, and forced users to convert std::string_view to std::string or const char* before calling Symbol::For.

Adding the std::string_view overload provides a more consistent API surface and avoids unnecessary string copies.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 63.65%. Comparing base (0add130) to head (7449c00).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1722      +/-   ##
==========================================
+ Coverage   63.61%   63.65%   +0.03%     
==========================================
  Files           3        3              
  Lines        2056     2058       +2     
  Branches      729      729              
==========================================
+ Hits         1308     1310       +2     
  Misses        162      162              
  Partials      586      586              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@umuoy1
Copy link
Copy Markdown
Contributor Author

umuoy1 commented Apr 12, 2026

@legendecas could you take a look at this PR? Thanks!

Copy link
Copy Markdown
Member

@legendecas legendecas left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM

Comment thread doc/symbol.md Outdated
Co-authored-by: Chengzhong Wu <legendecas@gmail.com>
@umuoy1
Copy link
Copy Markdown
Contributor Author

umuoy1 commented Apr 13, 2026

This suggestion has been addressed. Ready for merging, thanks!

@legendecas legendecas merged commit f65113b into nodejs:main Apr 15, 2026
60 checks passed
@github-project-automation github-project-automation bot moved this from Need Triage to Done in Node-API Team Project Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

4 participants