0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-29 23:16:30 +01:00
nodejs/doc/api
Gabriel Schulhof 8cb4ba982b 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

```C
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`.

PR-URL: https://github.com/nodejs/node/pull/28657
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-07-15 19:15:17 -07:00
..
addons.md doc: format try...catch consistently 2019-07-02 14:06:01 -04:00
assert.md doc: remove superfluous MDN link in assert.md 2019-07-13 10:06:05 -07:00
async_hooks.md doc: remove "note that" from async_hooks.md 2019-06-23 07:10:04 -07:00
buffer.md doc: add example for Buffer.isEncoding() 2019-06-23 23:00:03 -07:00
child_process.md doc: format Unix consistently 2019-07-08 13:34:05 -04:00
cli.md doc: remove "note that" from cli.md 2019-06-23 07:10:01 -07:00
cluster.md doc: format Unix consistently 2019-07-08 13:34:05 -04:00
console.md doc: remove "note that" from console.md 2019-06-23 07:09:57 -07:00
crypto.md doc: add documentation for createDiffieHellmanGroup 2019-07-14 23:17:00 -07:00
debugger.md
deprecations.md doc: drop 'for more details' in deprecations 2019-07-13 10:08:35 -04:00
dgram.md doc: remove "note that" from dgram.md 2019-06-23 07:09:54 -07:00
dns.md doc: remove unnecessary stability specifiers 2019-07-02 13:13:03 -04:00
documentation.md doc: simplify system call material in doc overview 2019-06-02 00:10:01 +02:00
domain.md doc: remove "note that" from domain.md 2019-06-23 07:09:50 -07:00
errors.md doc: format try...catch consistently 2019-07-02 14:06:01 -04:00
esm.md doc: small grammar correction 2019-07-15 13:19:46 -04:00
events.md doc: remove "note that" from events.md 2019-06-23 07:09:34 -07:00
fs.md doc: format Unix consistently 2019-07-08 13:34:05 -04:00
globals.md
http2.md doc: clarify http2 server.close() behavior 2019-07-08 13:38:06 -04:00
http.md Revert "http: fix test where aborted should not be emitted" 2019-07-15 08:40:19 -07:00
https.md 2019-06-27, Version 12.5.0 (Current) 2019-06-27 15:55:50 +02:00
index.md
inspector.md
intl.md
modules.md doc: remove "note that" from modules.md 2019-06-23 07:07:39 -07:00
n-api.md doc: update js-native-api example 2019-07-15 19:15:17 -07:00
net.md doc: format Unix consistently 2019-07-08 13:34:05 -04:00
os.md doc: format Unix consistently 2019-07-08 13:34:05 -04:00
path.md
perf_hooks.md perf_hooks: add HttpRequest statistics monitoring #28445 2019-07-12 00:36:27 +02:00
policy.md
process.md doc: mark process.report as experimental 2019-07-14 10:09:58 -04:00
punycode.md
querystring.md
readline.md readline: expose stream API in clearScreenDown() 2019-07-13 16:20:06 -04:00
repl.md
report.md report: modify getReport() to return an Object 2019-07-12 14:48:09 -07:00
stream.md doc: add missing version metadata for Readable.from 2019-07-15 22:28:36 +02:00
string_decoder.md
synopsis.md doc: move Usage and Example to same header level 2019-07-09 19:45:20 -07:00
timers.md
tls.md doc: make tls links more readable 2019-07-08 13:42:23 -04:00
tracing.md doc: document trace-events category for dns requests 2019-06-12 19:42:54 -07:00
tty.md doc: remove "note that" from tty.md 2019-06-23 07:07:31 -07:00
url.md doc: remove "note that" from url.md 2019-06-23 07:07:30 -07:00
util.md doc: remove "note that" from util.md 2019-06-23 07:07:28 -07:00
v8.md src: export number_of_native_contexts and number_of_detached_contexts 2019-05-30 15:25:55 +02:00
vm.md
worker_threads.md 2019-06-27, Version 12.5.0 (Current) 2019-06-27 15:55:50 +02:00
zlib.md doc: remove URLs from zlib docs 2019-07-08 13:42:45 -04:00