Skip to content

Commit

Permalink
doc: correct JavaScript primitive value names in n-api.md
Browse files Browse the repository at this point in the history
PR-URL: #39129
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Michael Dawson <midawson@redhat.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
legendecas authored and targos committed Sep 4, 2021
1 parent c8c290a commit 82458b3
Showing 1 changed file with 54 additions and 54 deletions.
108 changes: 54 additions & 54 deletions doc/api/n-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ clear the exception. On success, result will contain the handle to
the last JavaScript `Object` thrown. If it is determined, after
retrieving the exception, the exception cannot be handled after all
it can be re-thrown it with [`napi_throw`][] where error is the
JavaScript `Error` object to be thrown.
JavaScript value to be thrown.
The following utility functions are also available in case native code
needs to throw an exception or determine if a `napi_value` is an instance
Expand Down Expand Up @@ -1152,7 +1152,7 @@ NAPI_EXTERN napi_status napi_create_error(napi_env env,
* `[in] env`: The environment that the API is invoked under.
* `[in] code`: Optional `napi_value` with the string for the error code to be
associated with the error.
* `[in] msg`: `napi_value` that references a JavaScript `String` to be used as
* `[in] msg`: `napi_value` that references a JavaScript `string` to be used as
the message for the `Error`.
* `[out] result`: `napi_value` representing the error created.

Expand All @@ -1176,7 +1176,7 @@ NAPI_EXTERN napi_status napi_create_type_error(napi_env env,
* `[in] env`: The environment that the API is invoked under.
* `[in] code`: Optional `napi_value` with the string for the error code to be
associated with the error.
* `[in] msg`: `napi_value` that references a JavaScript `String` to be used as
* `[in] msg`: `napi_value` that references a JavaScript `string` to be used as
the message for the `Error`.
* `[out] result`: `napi_value` representing the error created.
Expand All @@ -1200,7 +1200,7 @@ NAPI_EXTERN napi_status napi_create_range_error(napi_env env,
* `[in] env`: The environment that the API is invoked under.
* `[in] code`: Optional `napi_value` with the string for the error code to be
associated with the error.
* `[in] msg`: `napi_value` that references a JavaScript `String` to be used as
* `[in] msg`: `napi_value` that references a JavaScript `string` to be used as
the message for the `Error`.
* `[out] result`: `napi_value` representing the error created.

Expand Down Expand Up @@ -2322,14 +2322,14 @@ napi_status napi_create_symbol(napi_env env,
* `[in] env`: The environment that the API is invoked under.
* `[in] description`: Optional `napi_value` which refers to a JavaScript
`String` to be set as the description for the symbol.
* `[out] result`: A `napi_value` representing a JavaScript `Symbol`.
`string` to be set as the description for the symbol.
* `[out] result`: A `napi_value` representing a JavaScript `symbol`.
Returns `napi_ok` if the API succeeded.
This API creates a JavaScript `Symbol` object from a UTF8-encoded C string.
This API creates a JavaScript `symbol` value from a UTF8-encoded C string.
The JavaScript `Symbol` type is described in [Section 19.4][]
The JavaScript `symbol` type is described in [Section 19.4][]
of the ECMAScript Language Specification.
#### napi_create_typedarray
Expand Down Expand Up @@ -2416,14 +2416,14 @@ napi_status napi_create_int32(napi_env env, int32_t value, napi_value* result)

* `[in] env`: The environment that the API is invoked under.
* `[in] value`: Integer value to be represented in JavaScript.
* `[out] result`: A `napi_value` representing a JavaScript `Number`.
* `[out] result`: A `napi_value` representing a JavaScript `number`.

Returns `napi_ok` if the API succeeded.

This API is used to convert from the C `int32_t` type to the JavaScript
`Number` type.
`number` type.

The JavaScript `Number` type is described in
The JavaScript `number` type is described in
[Section 6.1.6][] of the ECMAScript Language Specification.

#### napi_create_uint32
Expand All @@ -2438,14 +2438,14 @@ napi_status napi_create_uint32(napi_env env, uint32_t value, napi_value* result)
* `[in] env`: The environment that the API is invoked under.
* `[in] value`: Unsigned integer value to be represented in JavaScript.
* `[out] result`: A `napi_value` representing a JavaScript `Number`.
* `[out] result`: A `napi_value` representing a JavaScript `number`.
Returns `napi_ok` if the API succeeded.
This API is used to convert from the C `uint32_t` type to the JavaScript
`Number` type.
`number` type.
The JavaScript `Number` type is described in
The JavaScript `number` type is described in
[Section 6.1.6][] of the ECMAScript Language Specification.
#### napi_create_int64
Expand All @@ -2460,14 +2460,14 @@ napi_status napi_create_int64(napi_env env, int64_t value, napi_value* result)

* `[in] env`: The environment that the API is invoked under.
* `[in] value`: Integer value to be represented in JavaScript.
* `[out] result`: A `napi_value` representing a JavaScript `Number`.
* `[out] result`: A `napi_value` representing a JavaScript `number`.

Returns `napi_ok` if the API succeeded.

This API is used to convert from the C `int64_t` type to the JavaScript
`Number` type.
`number` type.

The JavaScript `Number` type is described in [Section 6.1.6][]
The JavaScript `number` type is described in [Section 6.1.6][]
of the ECMAScript Language Specification. Note the complete range of `int64_t`
cannot be represented with full precision in JavaScript. Integer values
outside the range of [`Number.MIN_SAFE_INTEGER`][] `-(2**53 - 1)` -
Expand All @@ -2485,14 +2485,14 @@ napi_status napi_create_double(napi_env env, double value, napi_value* result)
* `[in] env`: The environment that the API is invoked under.
* `[in] value`: Double-precision value to be represented in JavaScript.
* `[out] result`: A `napi_value` representing a JavaScript `Number`.
* `[out] result`: A `napi_value` representing a JavaScript `number`.
Returns `napi_ok` if the API succeeded.
This API is used to convert from the C `double` type to the JavaScript
`Number` type.
`number` type.
The JavaScript `Number` type is described in
The JavaScript `number` type is described in
[Section 6.1.6][] of the ECMAScript Language Specification.
#### napi_create_bigint_int64
Expand Down Expand Up @@ -2581,14 +2581,14 @@ napi_status napi_create_string_latin1(napi_env env,
* `[in] str`: Character buffer representing an ISO-8859-1-encoded string.
* `[in] length`: The length of the string in bytes, or `NAPI_AUTO_LENGTH` if it
is null-terminated.
* `[out] result`: A `napi_value` representing a JavaScript `String`.
* `[out] result`: A `napi_value` representing a JavaScript `string`.
Returns `napi_ok` if the API succeeded.
This API creates a JavaScript `String` object from an ISO-8859-1-encoded C
This API creates a JavaScript `string` value from an ISO-8859-1-encoded C
string. The native string is copied.
The JavaScript `String` type is described in
The JavaScript `string` type is described in
[Section 6.1.4][] of the ECMAScript Language Specification.
#### napi_create_string_utf16
Expand All @@ -2608,14 +2608,14 @@ napi_status napi_create_string_utf16(napi_env env,
* `[in] str`: Character buffer representing a UTF16-LE-encoded string.
* `[in] length`: The length of the string in two-byte code units, or
`NAPI_AUTO_LENGTH` if it is null-terminated.
* `[out] result`: A `napi_value` representing a JavaScript `String`.
* `[out] result`: A `napi_value` representing a JavaScript `string`.

Returns `napi_ok` if the API succeeded.

This API creates a JavaScript `String` object from a UTF16-LE-encoded C string.
This API creates a JavaScript `string` value from a UTF16-LE-encoded C string.
The native string is copied.

The JavaScript `String` type is described in
The JavaScript `string` type is described in
[Section 6.1.4][] of the ECMAScript Language Specification.

#### napi_create_string_utf8
Expand All @@ -2635,14 +2635,14 @@ napi_status napi_create_string_utf8(napi_env env,
* `[in] str`: Character buffer representing a UTF8-encoded string.
* `[in] length`: The length of the string in bytes, or `NAPI_AUTO_LENGTH` if it
is null-terminated.
* `[out] result`: A `napi_value` representing a JavaScript `String`.
* `[out] result`: A `napi_value` representing a JavaScript `string`.
Returns `napi_ok` if the API succeeded.
This API creates a JavaScript `String` object from a UTF8-encoded C string.
This API creates a JavaScript `string` value from a UTF8-encoded C string.
The native string is copied.
The JavaScript `String` type is described in
The JavaScript `string` type is described in
[Section 6.1.4][] of the ECMAScript Language Specification.
### Functions to convert from Node-API to C types
Expand Down Expand Up @@ -2806,7 +2806,7 @@ napi_status napi_get_dataview_info(napi_env env,
* `[in] env`: The environment that the API is invoked under.
* `[in] dataview`: `napi_value` representing the `DataView` whose
properties to query.
* `[out] byte_length`: `Number` of bytes in the `DataView`.
* `[out] byte_length`: Number of bytes in the `DataView`.
* `[out] data`: The data buffer underlying the `DataView`.
If byte_length is `0`, this may be `NULL` or any other pointer value.
* `[out] arraybuffer`: `ArrayBuffer` underlying the `DataView`.
Expand Down Expand Up @@ -2879,15 +2879,15 @@ napi_status napi_get_value_double(napi_env env,
```

* `[in] env`: The environment that the API is invoked under.
* `[in] value`: `napi_value` representing JavaScript `Number`.
* `[in] value`: `napi_value` representing JavaScript `number`.
* `[out] result`: C double primitive equivalent of the given JavaScript
`Number`.
`number`.

Returns `napi_ok` if the API succeeded. If a non-number `napi_value` is passed
in it returns `napi_number_expected`.

This API returns the C double primitive equivalent of the given JavaScript
`Number`.
`number`.

#### napi_get_value_bigint_int64
<!-- YAML
Expand Down Expand Up @@ -3005,15 +3005,15 @@ napi_status napi_get_value_int32(napi_env env,
```
* `[in] env`: The environment that the API is invoked under.
* `[in] value`: `napi_value` representing JavaScript `Number`.
* `[in] value`: `napi_value` representing JavaScript `number`.
* `[out] result`: C `int32` primitive equivalent of the given JavaScript
`Number`.
`number`.
Returns `napi_ok` if the API succeeded. If a non-number `napi_value`
is passed in `napi_number_expected`.
This API returns the C `int32` primitive equivalent
of the given JavaScript `Number`.
of the given JavaScript `number`.
If the number exceeds the range of the 32 bit integer, then the result is
truncated to the equivalent of the bottom 32 bits. This can result in a large
Expand All @@ -3035,17 +3035,17 @@ napi_status napi_get_value_int64(napi_env env,
```

* `[in] env`: The environment that the API is invoked under.
* `[in] value`: `napi_value` representing JavaScript `Number`.
* `[in] value`: `napi_value` representing JavaScript `number`.
* `[out] result`: C `int64` primitive equivalent of the given JavaScript
`Number`.
`number`.

Returns `napi_ok` if the API succeeded. If a non-number `napi_value`
is passed in it returns `napi_number_expected`.

This API returns the C `int64` primitive equivalent of the given JavaScript
`Number`.
`number`.

`Number` values outside the range of [`Number.MIN_SAFE_INTEGER`][]
`number` values outside the range of [`Number.MIN_SAFE_INTEGER`][]
`-(2**53 - 1)` - [`Number.MAX_SAFE_INTEGER`][] `(2**53 - 1)` will lose
precision.

Expand Down Expand Up @@ -3076,7 +3076,7 @@ napi_status napi_get_value_string_latin1(napi_env env,
* `[out] result`: Number of bytes copied into the buffer, excluding the null
terminator.
Returns `napi_ok` if the API succeeded. If a non-`String` `napi_value`
Returns `napi_ok` if the API succeeded. If a non-`string` `napi_value`
is passed in it returns `napi_string_expected`.
This API returns the ISO-8859-1-encoded string corresponding the value passed
Expand Down Expand Up @@ -3106,7 +3106,7 @@ napi_status napi_get_value_string_utf8(napi_env env,
* `[out] result`: Number of bytes copied into the buffer, excluding the null
terminator.

Returns `napi_ok` if the API succeeded. If a non-`String` `napi_value`
Returns `napi_ok` if the API succeeded. If a non-`string` `napi_value`
is passed in it returns `napi_string_expected`.

This API returns the UTF8-encoded string corresponding the value passed in.
Expand Down Expand Up @@ -3135,7 +3135,7 @@ napi_status napi_get_value_string_utf16(napi_env env,
* `[out] result`: Number of 2-byte code units copied into the buffer, excluding
the null terminator.
Returns `napi_ok` if the API succeeded. If a non-`String` `napi_value`
Returns `napi_ok` if the API succeeded. If a non-`string` `napi_value`
is passed in it returns `napi_string_expected`.
This API returns the UTF16-encoded string corresponding the value passed in.
Expand All @@ -3153,7 +3153,7 @@ napi_status napi_get_value_uint32(napi_env env,
```

* `[in] env`: The environment that the API is invoked under.
* `[in] value`: `napi_value` representing JavaScript `Number`.
* `[in] value`: `napi_value` representing JavaScript `number`.
* `[out] result`: C primitive equivalent of the given `napi_value` as a
`uint32_t`.

Expand Down Expand Up @@ -3243,8 +3243,8 @@ of the [ECMAScript Language Specification][].

These APIs support doing one of the following:

1. Coerce JavaScript values to specific JavaScript types (such as `Number` or
`String`).
1. Coerce JavaScript values to specific JavaScript types (such as `number` or
`string`).
2. Check the type of a JavaScript value.
3. Check for equality between two JavaScript values.

Expand Down Expand Up @@ -3284,7 +3284,7 @@ napi_status napi_coerce_to_number(napi_env env,

* `[in] env`: The environment that the API is invoked under.
* `[in] value`: The JavaScript value to coerce.
* `[out] result`: `napi_value` representing the coerced JavaScript `Number`.
* `[out] result`: `napi_value` representing the coerced JavaScript `number`.

Returns `napi_ok` if the API succeeded.

Expand Down Expand Up @@ -3328,7 +3328,7 @@ napi_status napi_coerce_to_string(napi_env env,

* `[in] env`: The environment that the API is invoked under.
* `[in] value`: The JavaScript value to coerce.
* `[out] result`: `napi_value` representing the coerced JavaScript `String`.
* `[out] result`: `napi_value` representing the coerced JavaScript `string`.

Returns `napi_ok` if the API succeeded.

Expand Down Expand Up @@ -3612,7 +3612,7 @@ following forms:
* Named: a simple UTF8-encoded string
* Integer-Indexed: an index value represented by `uint32_t`
* JavaScript value: these are represented in Node-API by `napi_value`. This can
be a `napi_value` representing a `String`, `Number`, or `Symbol`.
be a `napi_value` representing a `string`, `number`, or `symbol`.

Node-API values are represented by the type `napi_value`.
Any Node-API call that requires a JavaScript value takes in a `napi_value`.
Expand Down Expand Up @@ -3807,7 +3807,7 @@ typedef struct {
} napi_property_descriptor;
```

* `utf8name`: Optional `String` describing the key for the property,
* `utf8name`: Optional string describing the key for the property,
encoded as UTF8. One of `utf8name` or `name` must be provided for the
property.
* `name`: Optional `napi_value` that points to a JavaScript string or symbol
Expand Down Expand Up @@ -4003,8 +4003,8 @@ napi_status napi_has_own_property(napi_env env,
Returns `napi_ok` if the API succeeded.
This API checks if the `Object` passed in has the named own property. `key` must
be a string or a `Symbol`, or an error will be thrown. Node-API will not perform
any conversion between data types.
be a `string` or a `symbol`, or an error will be thrown. Node-API will not
perform any conversion between data types.
#### napi_set_named_property
<!-- YAML
Expand Down Expand Up @@ -4281,7 +4281,7 @@ NAPI_EXTERN napi_status napi_call_function(napi_env env,
```

* `[in] env`: The environment that the API is invoked under.
* `[in] recv`: The `this` object passed to the called function.
* `[in] recv`: The `this` value passed to the called function.
* `[in] func`: `napi_value` representing the JavaScript function to be invoked.
* `[in] argc`: The count of elements in the `argv` array.
* `[in] argv`: Array of `napi_values` representing JavaScript values passed in
Expand Down Expand Up @@ -5247,7 +5247,7 @@ NAPI_EXTERN napi_status napi_make_callback(napi_env env,
for `async_context` does not result in an error. However, this results
in incorrect operation of async hooks. Potential issues include loss of
async context when using the `AsyncLocalStorage` API.
* `[in] recv`: The `this` object passed to the called function.
* `[in] recv`: The `this` value passed to the called function.
* `[in] func`: `napi_value` representing the JavaScript function to be invoked.
* `[in] argc`: The count of elements in the `argv` array.
* `[in] argv`: Array of JavaScript values as `napi_value` representing the
Expand Down

0 comments on commit 82458b3

Please sign in to comment.