summaryrefslogtreecommitdiff
path: root/doc/api/n-api.md
AgeCommit message (Collapse)Author
2019-01-21n-api: mark thread-safe function as stableGabriel Schulhof
Fixes: https://github.com/nodejs/node/issues/24249 PR-URL: https://github.com/nodejs/node/pull/25556 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2019-01-13doc: fix `napi_open_callback_scope` descriptionPhilipp Renoth
- parameter `resource_object` is mandatory PR-URL: https://github.com/nodejs/node/pull/25366 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2019-01-09doc: add clarification for exception behaviourMichael Dawson
Document current behaviour where some methods can be called when an exception is pending, while others cannot and explain the behaviour. PR-URL: https://github.com/nodejs/node/pull/25339 Refs: https://github.com/nodejs/abi-stable-node/issues/356 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2018-12-25doc: fix NAPI typoPhilipp Renoth
PR-URL: https://github.com/nodejs/node/pull/25216 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-11-28doc: sort bottom-of-file markdown linksSam Roberts
Reapply https://github.com/nodejs/node/pull/12726 It would be nice to have the sort check applied as part of doc testing, but this change doesn't implement that. PR-URL: https://github.com/nodejs/node/pull/24679 Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2018-11-23doc: mark napi_add_finalizer experimentalMichael Dawson
This was missed when the function was added. As it is experimental in the code it should also be experimental in the docs. Fixes: https://github.com/nodejs/node/issues/24509 PR-URL: https://github.com/nodejs/node/pull/24572 Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-11-17src: factor out Node.js-agnostic N-APIsGabriel Schulhof
Split the Node.js ECMAScript API (N-EAPI?) into its own header and implementation files. The motivation is that the ECMAScript API stand on its own so it might be embedded separately, implementation and all. Portions of the implementation used by both files are stored in `node_api_impl.h`. The checked boxes below indicate that the given API remains in `node_api.h`, whereas the lack of a checkbox indicates that the API was moved to `node_ecma_api.h`. * [x] NAPI_MODULE * [x] NAPI_MODULE_INIT * [x] napi_acquire_threadsafe_function * [x] napi_add_env_cleanup_hook * [x] napi_async_destroy * [x] napi_async_init * [x] napi_call_threadsafe_function * [x] napi_cancel_async_work * [x] napi_close_callback_scope * [x] napi_create_async_work * [x] napi_create_buffer * [x] napi_create_buffer_copy * [x] napi_create_external_buffer * [x] napi_create_threadsafe_function * [x] napi_delete_async_work * [x] napi_fatal_error * [x] napi_fatal_exception * [x] napi_get_buffer_info * [x] napi_get_node_version * [x] napi_get_threadsafe_function_context * [x] napi_get_uv_event_loop * [x] napi_is_buffer * [x] napi_make_callback * [x] napi_module_register * [x] napi_open_callback_scope * [x] napi_queue_async_work * [x] napi_ref_threadsafe_function * [x] napi_release_threadsafe_function * [x] napi_remove_env_cleanup_hook * [x] napi_unref_threadsafe_function * [ ] napi_add_finalizer * [ ] napi_adjust_external_memory * [ ] napi_call_function * [ ] napi_close_escapable_handle_scope * [ ] napi_close_handle_scope * [ ] napi_coerce_to_bool * [ ] napi_coerce_to_number * [ ] napi_coerce_to_object * [ ] napi_coerce_to_string * [ ] napi_create_array * [ ] napi_create_arraybuffer * [ ] napi_create_array_with_length * [ ] napi_create_bigint_int64 * [ ] napi_create_bigint_uint64 * [ ] napi_create_bigint_words * [ ] napi_create_dataview * [ ] napi_create_double * [ ] napi_create_error * [ ] napi_create_external * [ ] napi_create_external_arraybuffer * [ ] napi_create_function * [ ] napi_create_int32 * [ ] napi_create_int64 * [ ] napi_create_object * [ ] napi_create_promise * [ ] napi_create_range_error * [ ] napi_create_reference * [ ] napi_create_string_latin1 * [ ] napi_create_string_utf16 * [ ] napi_create_string_utf8 * [ ] napi_create_symbol * [ ] napi_create_typedarray * [ ] napi_create_type_error * [ ] napi_create_uint32 * [ ] napi_define_class * [ ] napi_define_properties * [ ] napi_delete_element * [ ] napi_delete_property * [ ] napi_delete_reference * [ ] napi_escape_handle * [ ] napi_get_and_clear_last_exception * [ ] napi_get_arraybuffer_info * [ ] napi_get_array_length * [ ] napi_get_boolean * [ ] napi_get_cb_info * [ ] napi_get_dataview_info * [ ] napi_get_element * [ ] napi_get_global * [ ] napi_get_last_error_info * [ ] napi_get_named_property * [ ] napi_get_new_target * [ ] napi_get_null * [ ] napi_get_property * [ ] napi_get_property_names * [ ] napi_get_prototype * [ ] napi_get_reference_value * [ ] napi_get_typedarray_info * [ ] napi_get_undefined * [ ] napi_get_value_bigint_int64 * [ ] napi_get_value_bigint_uint64 * [ ] napi_get_value_bigint_words * [ ] napi_get_value_bool * [ ] napi_get_value_double * [ ] napi_get_value_external * [ ] napi_get_value_int32 * [ ] napi_get_value_int64 * [ ] napi_get_value_string_latin1 * [ ] napi_get_value_string_utf16 * [ ] napi_get_value_string_utf8 * [ ] napi_get_value_uint32 * [ ] napi_get_version * [ ] napi_has_element * [ ] napi_has_named_property * [ ] napi_has_own_property * [ ] napi_has_property * [ ] napi_instanceof * [ ] napi_is_array * [ ] napi_is_arraybuffer * [ ] napi_is_dataview * [ ] napi_is_error * [ ] napi_is_exception_pending * [ ] napi_is_promise * [ ] napi_is_typedarray * [ ] napi_new_instance * [ ] napi_open_escapable_handle_scope * [ ] napi_open_handle_scope * [ ] napi_reference_ref * [ ] napi_reference_unref * [ ] napi_reject_deferred * [ ] napi_remove_wrap * [ ] napi_resolve_deferred * [ ] napi_run_script * [ ] napi_set_element * [ ] napi_set_named_property * [ ] napi_set_property * [ ] napi_strict_equals * [ ] napi_throw * [ ] napi_throw_error * [ ] napi_throw_range_error * [ ] napi_throw_type_error * [ ] napi_typeof * [ ] napi_unwrap * [ ] napi_wrap PR-URL: https://github.com/nodejs/node/pull/23786 Reviewed-By: Yazhong Liu <yorkiefixer@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2018-11-16doc: better linkage to node-addon-apiMichael Dawson
One of the comments we got at the N-API workshop at NodeConfEU was that we should have a better link to node-addon-api and the docs in the main API docs for N-API. The goal being to help people find node-addon-api and potentially start with the node-addon-api docs instead if they are using C++. This expands and strengthens the link along with a recommendation that starting with the node-addon-api docs might make sense. PR-URL: https://github.com/nodejs/node/pull/24371 Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
2018-10-09benchmark,doc,lib,src,test,tools: fix typosBrandon Smith
PR-URL: https://github.com/nodejs/node/pull/23302 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2018-10-09doc: add link to ABI guideGabriel Schulhof
Provides a link from the N-API reference to the guide discussing ABI stability in greater depth. Re: https://github.com/nodejs/abi-stable-node/issues/332 PR-URL: https://github.com/nodejs/node/pull/23287/ Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
2018-10-07doc: fix minor typo in n-api.mdAleksey Chemakin
Correct parameter name for `napi_is_error` description. PR-URL: https://github.com/nodejs/node/pull/23310 Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2018-09-24doc: fix optional parameters in n-api.mdLars-Magnus Skog
The thread_finalize_data and thread_finalize_cb parameters in napi_create_threadsafe_function are optional. PR-URL: https://github.com/nodejs/node/pull/22998 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
2018-09-12n-api: add generic finalizer callbackGabriel Schulhof
Add `napi_add_finalizer()`, which provides the ability to attach data to an arbitrary object and be notified when that object is garbage- collected so as to have an opportunity to delete the data previously attached. This differs from `napi_wrap()` in that it does not use up the private slot on the object, and is therefore neither removable, nor retrievable after the call to `napi_add_finalizer()`. It is assumed that the data is accessible by other means, yet it must be tied to the lifetime of the object. This is the case for data passed to a dynamically created function which is itself heap-allocated and must therefore be freed along with the function. Fixes: https://github.com/nodejs/abi-stable-node/issues/313 PR-URL: https://github.com/nodejs/node/pull/22244 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2018-09-03doc: add blurb about implications of ABI stabilityGabriel Schulhof
Mention that ABI stability can be achieved only by linking to ABI- stable parts of Node.js and to other libraries which are ABI-stable. PR-URL: https://github.com/nodejs/node/pull/22508 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2018-08-29doc: remove redundant 'Example:' and similar notesVse Mozhet Byt
Some nits were also fixed in passing. PR-URL: https://github.com/nodejs/node/pull/22537 Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2018-08-21doc: update wrapping-related documentationGabriel Schulhof
Update the N-API documentation to reflect that wrapping no longer affects the object's prototype chain. PR-URL: https://github.com/nodejs/node/pull/22363 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2018-07-23doc: link n-api module init to multi-load addonsGabriel Schulhof
Add a blurb to the documentation of `NAPI_MODULE_INIT()` pointing to the discussion of the consequences of providing an addon that can be loaded multiple times from multiple contexts. PR-URL: https://github.com/nodejs/node/pull/21891 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-07-182018-07-18, Version 10.7.0 (Current)Michaël Zasso
Notable changes: * console: * The `console.timeLog()` method has been implemented. (https://github.com/nodejs/node/pull/21312) * deps: * Upgrade to libuv 1.22.0. (https://github.com/nodejs/node/pull/21731) * Upgrade to ICU 62.1 (Unicode 11, CLDR 33.1). (https://github.com/nodejs/node/pull/21728) * http: * Added support for passing both `timeout` and `agent` options to `http.request`. (https://github.com/nodejs/node/pull/21204) * inspector: * Expose the original console API in `require('inspector').console`. (https://github.com/nodejs/node/pull/21659) * napi: * Added experimental support for functions dealing with bigint numbers. (https://github.com/nodejs/node/pull/21226) * process: * The `process.hrtime.bigint()` method has been implemented. (https://github.com/nodejs/node/pull/21256) * Added the `--title` command line argument to set the process title on startup. (https://github.com/nodejs/node/pull/21477) * trace_events: * Added process_name metadata. (https://github.com/nodejs/node/pull/21477) * Added new collaborators * codebytere - Shelley Vohr PR-URL: https://github.com/nodejs/node/pull/21851
2018-07-12napi: add bigint supportGus Caplan
PR-URL: https://github.com/nodejs/node/pull/21226 Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com> Reviewed-By: Kyle Farnung <kfarnung@microsoft.com>
2018-07-05doc: fix doc for napi_create_functionGabriel Schulhof
Merge the two duplicate entries for `napi_create_function()`. Fixes: https://github.com/nodejs/node/issues/21606 PR-URL: https://github.com/nodejs/node/pull/21627/ Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2018-07-05n-api: restrict exports by versionKyle Farnung
* Move `napi_get_uv_event_loop` into the `NAPI_VERSION >= 2` section * Move `napi_open_callback_scope`, `napi_close_callback_scope`, `napi_fatal_exception`, `napi_add_env_cleanup_hook`, and `napi_remove_env_cleanup_hook` into the `NAPI_VERSION >= 3` section * Added a missing `added` property to `napi_get_uv_event_loop` in the docs * Added a `napiVersion` property to the docs and updated the parser and generator to use it. * Added usage documentation PR-URL: https://github.com/nodejs/node/pull/19962 Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2018-07-042018-07-04, Version 10.6.0 (Current)Michaël Zasso
Notable changes: * dns: * An experimental promisified version of the dns module is now available. Give it a try with `require('dns').promises`. [#21264](https://github.com/nodejs/node/pull/21264) * fs: * `fs.lchown` has been undeprecated now that libuv supports it. [#21498](https://github.com/nodejs/node/pull/21498) * lib: * `Atomics.wake` is being renamed to `Atomics.notify` in the ECMAScript specification ([reference](https://github.com/tc39/ecma262/pull/1220)). Since Node.js now has experimental support for worker threads, we are being proactive and added a `notify` alias, while emitting a warning if `wake` is used. [#21413](https://github.com/nodejs/node/pull/21413) [#21518](https://github.com/nodejs/node/pull/21518) * n-api: * Add API for asynchronous functions. [#17887](https://github.com/nodejs/node/pull/17887) * util: * `util.inspect` is now able to return a result instead of throwing when the maximum call stack size is exceeded during inspection. [#20725](https://github.com/nodejs/node/pull/20725) * vm: * Add `script.createCachedData()`. This API replaces the `produceCachedData` option of the `Script` constructor that is now deprecated. [#20300](https://github.com/nodejs/node/pull/20300) * worker: * Support for relative paths has been added to the `Worker` constructor. Paths are interpreted relative to the current working directory. [#21407](https://github.com/nodejs/node/pull/21407) PR-URL: https://github.com/nodejs/node/pull/21629
2018-07-02doc: fix some typos in N-API docsVse Mozhet Byt
PR-URL: https://github.com/nodejs/node/pull/21614 Reviewed-By: Weijia Wang <starkwang@126.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Yuta Hiroto <hello@hiroppy.me> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2018-06-29n-api: add API for asynchronous functionsGabriel Schulhof
Bundle a `uv_async_t`, a `uv_idle_t`, a `uv_mutex_t`, a `uv_cond_t`, and a `v8::Persistent<v8::Function>` to make it possible to call into JS from another thread. The API accepts a void data pointer and a callback which will be invoked on the loop thread and which will receive the `napi_value` representing the JavaScript function to call so as to perform the call into JS. The callback is run inside a `node::CallbackScope`. A `std::queue<void*>` is used to store calls from the secondary threads, and an idle loop is started by the `uv_async_t` callback on the loop thread to drain the queue, calling into JS with each item. Items can be added to the queue blockingly or non-blockingly. The thread-safe function can be referenced or unreferenced, with the same semantics as libuv handles. Re: https://github.com/nodejs/help/issues/1035 Re: https://github.com/nodejs/node/issues/20964 Fixes: https://github.com/nodejs/node/issues/13512 PR-URL: https://github.com/nodejs/node/pull/17887 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2018-06-18doc: eliminate _you_ from N-API docRich Trott
The STYLE_GUIDE indicates that personal pronouns like "you" should be avoided in reference documentation. Remove "you" from N-API doc. PR-URL: https://github.com/nodejs/node/pull/21382 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2018-06-14doc: clarify async execute callback usageMichael Dawson
Clarify that calls to N-API should be avoided in the 'execute' callback. PR-URL: https://github.com/nodejs/node/pull/21217 Refs: https://github.com/nodejs/help/issues/1318 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
2018-05-31doc: fix typo in n-api.mdohbarye
just replaced `than` with `that`. - wrong: the N-API functions than can be used to change - correct: the N-API functions that can be used to change Fixes: https://github.com/nodejs/node/issues/21049 PR-URL: https://github.com/nodejs/node/pull/21060 Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
2018-05-28doc: fix doc for napi_get_typedarray_infoMichael Dawson
The data pointer returned for the typedarray has already been adjusted by the offset so it does not point to the start of the buffer, instead id points to the start of the first element. I think we probably would have liked it to point to the start of the buffer, but we can't change as that would be a breaking change. Update the doc to match the implementation. PR-URL: https://github.com/nodejs/node/pull/20747 Fixes: https://github.com/nodejs/node-addon-api/issues/244 Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2018-05-232018-05-23, Version 10.2.0 (Current)Anna Henningsen
* addons: - Fixed a memory leak for users of `AsyncResource` and N-API. (Michael Dawson) https://github.com/nodejs/node/pull/20668 * assert: - The `error` parameter of `assert.throws()` can be an object containing regular expressions now. (Ruben Bridgewater) https://github.com/nodejs/node/pull/20485 * crypto: - The `authTagLength` option has been made more flexible (Tobias Nießen) https://github.com/nodejs/node/pull/20235) https://github.com/nodejs/node/pull/20039 * esm: - Builtin modules (e.g. `fs`) now provide named exports in ES6 modules. (Gus Caplan) https://github.com/nodejs/node/pull/20403 * http: - Handling of `close` and `aborted` events has been made more consistent. (Robert Nagy) https://github.com/nodejs/node/pull/20075 https://github.com/nodejs/node/pull/20611 * module: - add --preserve-symlinks-main (David Goldstein) https://github.com/nodejs/node/pull/19911 * timers: - `timeout.refresh()` has been added to the public API. (Jeremiah Senkpiel) https://github.com/nodejs/node/pull/20298 * Embedder support: - Functions for creating V8 `Isolate` and `Context` objects with Node.js-specific behaviour have been added to the API. (Allen Yonghuang Wang) https://github.com/nodejs/node/pull/20639 - Node.js `Environment`s clean up resources before exiting now. (Anna Henningsen) https://github.com/nodejs/node/pull/19377 - Support for multi-threaded embedding has been improved. (Anna Henningsen) https://github.com/nodejs/node/pull/20542 https://github.com/nodejs/node/pull/20539 https://github.com/nodejs/node/pull/20541 PR-URL: https://github.com/nodejs/node/pull/20724
2018-05-14doc: fixup NODE_EXTERN -> NAPI_EXTERNMichael Dawson
Seems like we missed updating doc when we changed from NODE_EXTERN to NAPI_EXTERN PR-URL: https://github.com/nodejs/node/pull/20641 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2018-05-14doc: fix signature for napi_create_range_errorMichael Dawson
Fixes: https://github.com/nodejs/node/issues/20623 PR-URL: https://github.com/nodejs/node/pull/20641 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2018-05-10src: add environment cleanup hooksAnna Henningsen
This adds pairs of methods to the `Environment` class and to public APIs which can add and remove cleanup handlers. Unlike `AtExit`, this API targets addon developers rather than embedders, giving them (and Node’s internals) the ability to register per-`Environment` cleanup work. We may want to replace `AtExit` with this API at some point. Many thanks for Stephen Belanger for reviewing the original version of this commit in the Ayo.js project. Refs: https://github.com/ayojs/ayo/pull/82 PR-URL: https://github.com/nodejs/node/pull/19377 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
2018-05-09doc: fix missing napi_get_typedarray_info() paramGabriel Schulhof
Also, make the type name notation more consistent. PR-URL: https://github.com/nodejs/node/pull/20631 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
2018-05-06doc: fix N-API property descriptor documentationGabriel Schulhof
PR-URL: https://github.com/nodejs/node/pull/20433 Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-05-03doc: cleanup n-api.md docMichael Dawson
Partial doc cleanup as per https://github.com/nodejs/node/issues/20421 PR-URL: https://github.com/nodejs/node/pull/20430 Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2018-05-03doc: add more missing backticksVse Mozhet Byt
Also, fix some other nits in passing (formatting, punctuation, typos, redundancy, obsoleteness). PR-URL: https://github.com/nodejs/node/pull/20438 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-05-02n-api: test and doc napi_throw() of a primitiveGabriel Schulhof
Ensure that napi_throw() is able to throw a primitive value, and document that it is able to throw any JavaScript value. Fixes: https://github.com/nodejs/abi-stable-node/issues/309 PR-URL: https://github.com/nodejs/node/pull/20428 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-05-02doc: add missing periods or colonsVse Mozhet Byt
Some other formatting nits were fixed and some superfluous descriptions were simplified in passing. PR-URL: https://github.com/nodejs/node/pull/20401 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-04-30doc: remove redundant table of contents for N-APIAyush Gupta
Since the table of contents is built dynamically when building the documentation, the additional table of contents is redundant and an extra overhead to maintain. PR-URL: https://github.com/nodejs/node/pull/20395 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-04-30n-api: document the look of napi_external valuesGabriel Schulhof
Describe what JavaScript values of type `napi_external` look like in JavaScript. Fixes: https://github.com/nodejs/abi-stable-node/issues/306 PR-URL: https://github.com/nodejs/node/pull/20426 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
2018-04-30n-api: document that native strings are copiedGabriel Schulhof
Mention that a copy is made of the native string by the napi_create_string_* APIs. Fixes: https://github.com/nodejs/abi-stable-node/issues/304 PR-URL: https://github.com/nodejs/node/pull/20425 Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
2018-04-30doc: refine napi_get_property_names() docGabriel Schulhof
Document that only enumerable, string-keyed properties are returned. Fixes: https://github.com/nodejs/abi-stable-node/issues/307 PR-URL: https://github.com/nodejs/node/pull/20427 Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
2018-04-29doc: add missing backticks in n-api.mdVse Mozhet Byt
Codify types, variable names, and code fragments checking patterns I've managed to think of. Some nits were also fixed in passing (add missing periods, remove extra line breaks etc). PR-URL: https://github.com/nodejs/node/pull/20390 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2018-04-23n-api: initialize a module via a special symbolGabriel Schulhof
Much like regular modules, N-API modules can also benefit from having a special symbol which they can expose. Fixes: https://github.com/nodejs/node/issues/19845 PR-URL: https://github.com/nodejs/node/pull/20161 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2018-04-21doc: remove "For example" expression in N-API docGabriel Schulhof
PR-URL: https://github.com/nodejs/node/pull/20187 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2018-04-17doc: fix suspicious heading emphasis in n-api.mdVse Mozhet Byt
PR-URL: https://github.com/nodejs/node/pull/20086 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Kyle Farnung <kfarnung@microsoft.com>
2018-04-14doc: add missing type=misc top commentsVse Mozhet Byt
PR-URL: https://github.com/nodejs/node/pull/20022 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2018-04-11doc: add quotes for event names + fix similar nitsVse Mozhet Byt
PR-URL: https://github.com/nodejs/node/pull/19915 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2018-04-08n-api: add more `int64_t` testsKyle Farnung
* Updated tests for `Number` and `int32_t` * Added new tests for `int64_t` * Updated N-API `int64_t` behavior to return zero for all non-finite numbers * Clarified the documentation for these calls. PR-URL: https://github.com/nodejs/node/pull/19402 Refs: https://github.com/nodejs/node-chakracore/pull/500 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2018-04-04doc: fix various nitsVse Mozhet Byt
* Replace 2 hyphens (--) by spaced m-dashes (—) as per STYLE_GUIDE.md. * Space infix operators. * Unify quotes in inline code spans (use only single quotes). * Unify `* Returns:` (eliminate deviations). * Dedupe spaces. PR-URL: https://github.com/nodejs/node/pull/19743 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>