src: add FromV8Value<T>() for integral and enum types
From the following comment in the pull request: https://github.com/nodejs/node/pull/57146#discussion_r1963799600
Add a template utility method FromV8Value<T>() to replace the repetitive static_cast<...>(value.As<>()‑>Value()) pattern. It also additionally adds compile‑time range checks for integers.
I've also replaced a bunch of static_casts with the new FromV8Value<T>()
Review requested:
- [ ] @nodejs/crypto
- [ ] @nodejs/net
Codecov Report
Attention: Patch coverage is 88.23529% with 2 lines in your changes missing coverage. Please review.
Project coverage is 90.27%. Comparing base (
9cc0195) to head (fabec6a). Report is 480 commits behind head on main.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| src/util-inl.h | 66.66% | 0 Missing and 2 partials :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## main #57931 +/- ##
==========================================
- Coverage 90.28% 90.27% -0.01%
==========================================
Files 630 630
Lines 186158 186160 +2
Branches 36484 36476 -8
==========================================
- Hits 168067 168057 -10
+ Misses 10974 10970 -4
- Partials 7117 7133 +16
| Files with missing lines | Coverage Δ | |
|---|---|---|
| src/crypto/crypto_keys.cc | 72.57% <100.00%> (+0.27%) |
:arrow_up: |
| src/node_file.cc | 76.76% <100.00%> (+0.04%) |
:arrow_up: |
| src/node_util.cc | 81.73% <100.00%> (-0.06%) |
:arrow_down: |
| src/node_v8.cc | 80.67% <100.00%> (-0.05%) |
:arrow_down: |
| src/node_zlib.cc | 78.76% <100.00%> (+0.34%) |
:arrow_up: |
| src/process_wrap.cc | 66.66% <100.00%> (ø) |
|
| src/udp_wrap.cc | 78.62% <100.00%> (ø) |
|
| src/util-inl.h | 80.68% <66.66%> (-0.30%) |
:arrow_down: |
: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.
Failed to start CI
⚠ No approving reviews found ✘ Refusing to run CI on potentially unsafe PRhttps://github.com/nodejs/node/actions/runs/14540925539
This now has a conflict with the main branch, can you rebase?
CI: https://ci.nodejs.org/job/node-test-pull-request/66545/
CI: https://ci.nodejs.org/job/node-test-pull-request/66553/
CI: https://ci.nodejs.org/job/node-test-pull-request/66564/
It worked thank you
On Sun, 4 May 2025 at 1:56 am, Node.js GitHub Bot @.***> wrote:
nodejs-github-bot left a comment (nodejs/node#57931) https://github.com/nodejs/node/pull/57931#issuecomment-2848684649
CI: https://ci.nodejs.org/job/node-test-pull-request/66564/
— Reply to this email directly, view it on GitHub https://github.com/nodejs/node/pull/57931#issuecomment-2848684649, or unsubscribe https://github.com/notifications/unsubscribe-auth/BQIUYLZAFWID422ZKHTNSYD24TRJFAVCNFSM6AAAAAB3NQ36XWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDQNBYGY4DINRUHE . You are receiving this because you are subscribed to this thread.Message ID: @.***>
CI: https://ci.nodejs.org/job/node-test-pull-request/66687/
CI: https://ci.nodejs.org/job/node-test-pull-request/66712/
CI: https://ci.nodejs.org/job/node-test-pull-request/66769/
CI: https://ci.nodejs.org/job/node-test-pull-request/67097/
CI: https://ci.nodejs.org/job/node-test-pull-request/67119/
CI: https://ci.nodejs.org/job/node-test-pull-request/67143/
Landed in faada65d16c754b047a5ddee524f4b989756b72b