node-api: use WriteV2 in napi_get_value_string_utf16
Since String::Write() is deprecated, use String::Write2() instead. That requires us to compute the correct number of characters ahead of time but removes the need for dealing with the return value.
Review requested:
- [ ] @nodejs/node-api
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 90.23%. Comparing base (
6de55f7) to head (da6a60e). Report is 306 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #58165 +/- ##
==========================================
+ Coverage 90.17% 90.23% +0.05%
==========================================
Files 630 633 +3
Lines 186503 186807 +304
Branches 36614 36665 +51
==========================================
+ Hits 168187 168565 +378
+ Misses 11124 11041 -83
- Partials 7192 7201 +9
| Files with missing lines | Coverage Δ | |
|---|---|---|
| src/js_native_api_v8.cc | 76.55% <100.00%> (+0.02%) |
:arrow_up: |
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
Could you also replace the other deprecated Write functions in this file - the WriteOneByte and WriteUtf8?
CI: https://ci.nodejs.org/job/node-test-pull-request/66810/
CI: https://ci.nodejs.org/job/node-test-pull-request/66835/
Landed in 971148c39a0eadaa3b4e2395d2574dee68648875
Adding https://github.com/nodejs/node/labels/dont-land-on-v22%2Ex as it looks like WriteV2 is not available on 22.x.