summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorGabriel Schulhof <gabriel.schulhof@intel.com>2018-07-02 18:20:06 -0400
committerGabriel Schulhof <gabriel.schulhof@intel.com>2018-07-05 21:20:35 -0400
commite55bdde92513ecf4915390c772f5ffa5da2c9f5e (patch)
treec6d66ce0393a2cf10941a2a9c0fd62e2d9512b75 /doc
parent3314b3a2f5d9abcf1deee565839f779d26c8672d (diff)
downloadandroid-node-v8-e55bdde92513ecf4915390c772f5ffa5da2c9f5e.tar.gz
android-node-v8-e55bdde92513ecf4915390c772f5ffa5da2c9f5e.tar.bz2
android-node-v8-e55bdde92513ecf4915390c772f5ffa5da2c9f5e.zip
doc: fix doc for napi_create_function
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>
Diffstat (limited to 'doc')
-rw-r--r--doc/api/n-api.md44
1 files changed, 8 insertions, 36 deletions
diff --git a/doc/api/n-api.md b/doc/api/n-api.md
index 982b15f496..cdb3fcaf82 100644
--- a/doc/api/n-api.md
+++ b/doc/api/n-api.md
@@ -1485,40 +1485,6 @@ structure, in most cases using a `TypedArray` will suffice.
For Node.js >=4 `Buffers` are `Uint8Array`s.
-#### napi_create_function
-<!-- YAML
-added: v8.0.0
-napiVersion: 1
--->
-```C
-napi_status napi_create_function(napi_env env,
- const char* utf8name,
- size_t length,
- napi_callback cb,
- void* data,
- napi_value* result)
-```
-
-- `[in] env`: The environment that the API is invoked under.
-- `[in] utf8name`: A string representing the name of the function encoded as
-UTF8.
-- `[in] length`: The length of the `utf8name` in bytes, or
-`NAPI_AUTO_LENGTH` if it is null-terminated.
-- `[in] cb`: A function pointer to the native function to be invoked when the
-created function is invoked from JavaScript.
-- `[in] data`: Optional arbitrary context data to be passed into the native
-function when it is invoked.
-- `[out] result`: A `napi_value` representing a JavaScript function.
-
-Returns `napi_ok` if the API succeeded.
-
-This API returns an N-API value corresponding to a JavaScript `Function` object.
-It's used to wrap native functions so that they can be invoked from JavaScript.
-
-JavaScript `Function`s are described in
-[Section 19.2](https://tc39.github.io/ecma262/#sec-function-objects)
-of the ECMAScript Language Specification.
-
#### napi_create_object
<!-- YAML
added: v8.0.0
@@ -3153,6 +3119,7 @@ napiVersion: 1
```C
napi_status napi_create_function(napi_env env,
const char* utf8name,
+ size_t length,
napi_callback cb,
void* data,
napi_value* result);
@@ -3161,6 +3128,8 @@ napi_status napi_create_function(napi_env env,
- `[in] env`: The environment that the API is invoked under.
- `[in] utf8Name`: The name of the function encoded as UTF8. This is visible
within JavaScript as the new function object's `name` property.
+- `[in] length`: The length of the `utf8name` in bytes, or
+`NAPI_AUTO_LENGTH` if it is null-terminated.
- `[in] cb`: The native function which should be called when this function
object is invoked.
- `[in] data`: User-provided data context. This will be passed back into the
@@ -3209,10 +3178,13 @@ const myaddon = require('./addon');
myaddon.sayHello();
```
-The string passed to require is not necessarily the name passed into
-`NAPI_MODULE` in the earlier snippet but the name of the target in `binding.gyp`
+The string passed to `require()` is the name of the target in `binding.gyp`
responsible for creating the `.node` file.
+JavaScript `Function`s are described in
+[Section 19.2](https://tc39.github.io/ecma262/#sec-function-objects)
+of the ECMAScript Language Specification.
+
### napi_get_cb_info
<!-- YAML
added: v8.0.0