doc: update js-native-api example
Update example that shows how to separate N-API code which is not Node.js-specific from code which defines a Node.js N-API addon. In its existing state the example uses the pattern
assert(napi_*() == napi_ok);
However, this would result in no N-API calls when building with
-DNDEBUG
.
This change moves away from assert and uses a macro NAPI_CALL()
which
throws the string corresponding to the non-napi_ok
status as a JS
exception and short-circuits the binding by returning NULL
.
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
documentation is changed or added -
commit message follows commit guidelines