Skip to content

No way to extract arguments by index in N-API modules? #27329

@dead-claudia

Description

@dead-claudia

Is your feature request related to a problem? Please describe.
In the V8 API, arbitrary arguments are accessible via the instance method v8::FunctionCallbackInfo<T>::operator[](int i). But this doesn't appear exposed through the API, and this can be useful when writing native extensions.

Describe the solution you'd like
Something like napi_get_argument(napi_env, napi_callback_info, size_t, napi_value *result) that would be direct sugar over that. It would return napi_ok normally and napi_invalid_arg if the index is out of range.

Describe alternatives you've considered
I briefly considered the alternative of mallocing the arguments and returning them that way, but I felt it didn't mesh as well with the non-allocating nature of the rest of the API.

Metadata

Metadata

Assignees

No one assigned

    Labels

    node-apiIssues and PRs related to the Node-API.questionIssues that look for answers.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions