Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Allows for strings of variable lengths to be passed in.
Since I didn't see any existing in-line comments, I did not add any.
I'm not sure what the safety implications are for using
Box
in this manner. Here's a recent discussion that seems relevant: rust-lang/unsafe-code-guidelines#157Passing NULL into napi_get_value_string_utf8 will return the size of the string.
https://nodejs.org/api/n-api.html#n_api_napi_get_value_string_utf8
Adapted from example provided here: https://github.com/nodejs/node-addon-examples/pull/107/files#diff-8252f94e35e4da5136727f8d25a119308698c527d26c04f4dc71ce90ca8fc85b
That PR is in connection with this issue: nodejs/node-addon-examples#83 (comment)