Skip to content

Commit c8d5bab

Browse files
Gabriel Schulhoftargos
Gabriel Schulhof
authored andcommitted
doc: fix doc for napi_create_function
Merge the two duplicate entries for `napi_create_function()`. Fixes: #21606 PR-URL: #21627 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Vse Mozhet Byt <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
1 parent 9776f1c commit c8d5bab

File tree

1 file changed

+8
-36
lines changed

1 file changed

+8
-36
lines changed

doc/api/n-api.md

+8-36
Original file line numberDiff line numberDiff line change
@@ -1485,40 +1485,6 @@ structure, in most cases using a `TypedArray` will suffice.
14851485

14861486
For Node.js >=4 `Buffers` are `Uint8Array`s.
14871487

1488-
#### napi_create_function
1489-
<!-- YAML
1490-
added: v8.0.0
1491-
napiVersion: 1
1492-
-->
1493-
```C
1494-
napi_status napi_create_function(napi_env env,
1495-
const char* utf8name,
1496-
size_t length,
1497-
napi_callback cb,
1498-
void* data,
1499-
napi_value* result)
1500-
```
1501-
1502-
- `[in] env`: The environment that the API is invoked under.
1503-
- `[in] utf8name`: A string representing the name of the function encoded as
1504-
UTF8.
1505-
- `[in] length`: The length of the `utf8name` in bytes, or
1506-
`NAPI_AUTO_LENGTH` if it is null-terminated.
1507-
- `[in] cb`: A function pointer to the native function to be invoked when the
1508-
created function is invoked from JavaScript.
1509-
- `[in] data`: Optional arbitrary context data to be passed into the native
1510-
function when it is invoked.
1511-
- `[out] result`: A `napi_value` representing a JavaScript function.
1512-
1513-
Returns `napi_ok` if the API succeeded.
1514-
1515-
This API returns an N-API value corresponding to a JavaScript `Function` object.
1516-
It's used to wrap native functions so that they can be invoked from JavaScript.
1517-
1518-
JavaScript `Function`s are described in
1519-
[Section 19.2](https://tc39.github.io/ecma262/#sec-function-objects)
1520-
of the ECMAScript Language Specification.
1521-
15221488
#### napi_create_object
15231489
<!-- YAML
15241490
added: v8.0.0
@@ -3153,6 +3119,7 @@ napiVersion: 1
31533119
```C
31543120
napi_status napi_create_function(napi_env env,
31553121
const char* utf8name,
3122+
size_t length,
31563123
napi_callback cb,
31573124
void* data,
31583125
napi_value* result);
@@ -3161,6 +3128,8 @@ napi_status napi_create_function(napi_env env,
31613128
- `[in] env`: The environment that the API is invoked under.
31623129
- `[in] utf8Name`: The name of the function encoded as UTF8. This is visible
31633130
within JavaScript as the new function object's `name` property.
3131+
- `[in] length`: The length of the `utf8name` in bytes, or
3132+
`NAPI_AUTO_LENGTH` if it is null-terminated.
31643133
- `[in] cb`: The native function which should be called when this function
31653134
object is invoked.
31663135
- `[in] data`: User-provided data context. This will be passed back into the
@@ -3209,10 +3178,13 @@ const myaddon = require('./addon');
32093178
myaddon.sayHello();
32103179
```
32113180

3212-
The string passed to require is not necessarily the name passed into
3213-
`NAPI_MODULE` in the earlier snippet but the name of the target in `binding.gyp`
3181+
The string passed to `require()` is the name of the target in `binding.gyp`
32143182
responsible for creating the `.node` file.
32153183

3184+
JavaScript `Function`s are described in
3185+
[Section 19.2](https://tc39.github.io/ecma262/#sec-function-objects)
3186+
of the ECMAScript Language Specification.
3187+
32163188
### napi_get_cb_info
32173189
<!-- YAML
32183190
added: v8.0.0

0 commit comments

Comments
 (0)