nodejs / nodejs/node-addon-api

Support C++20 span types

Open
#1,747 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

SemVer-major
Dominant language
C++
Stars
2.4k
Forks
499
Avg merge
2d 11h
Merged PRs (30d)
2

Description

node-addon-api's buffer-like types pass their backing memory as a raw pointer plus a separate length, both on the way out (Data() + a length accessor) and on the way in (the New/Copy factories). Callers must keep the two values in sync manually, with no bounds information attached to the pointer.

Once C++20 is the minimum supported standard, we should adopt std::span in both directions. These additions are ABI-compatible (existing pointer/length overloads stay), and give callers a single bounds-carrying handle that works with range-based for, <algorithm>, and <ranges>.

This can be an additive change with a C++ version guard.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the existing Data() and length accessor pair, then the New and Copy factories that accept pointer/length inputs. Review how the project handles C++ version guards and existing overloads. Done means additive std::span support in both directions, with the pointer/length overloads retained for ABI compatibility.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, nodejs
Domain
backend-api-design
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.