The environment that the API is invoked under.
representing the being queried.
The underlying data buffer of the
Length in bytes of the underlying data buffer.
Returns if the API succeeded.
This API is used to retrieve the underlying data buffer of an and
Use caution while using this API.
The lifetime of the underlying data
buffer is managed by the even after it's returned.
possible safe way to use this API is in conjunction with
which can be used to guarantee control over the
lifetime of the
It's also safe to use the returned data buffer
within the same callback as long as there are no calls to other APIs that might
trigger a GC.
Use caution while using this API since the underlying data buffer's
lifetime is not guaranteed if it's managed by the VM.
This returns the equivalent of (which is not the same as the function's property).
representing prototype of the given object.
representing the whose properties to query.
Scalar datatype of the elements within the
of elements in the
The data buffer underlying the typed array.
The byte offset within the data buffer from which
to start projecting the
This API returns various properties of a typed array.
of bytes in the
If a non-boolean is passed in it returns
This API retrieves the external data pointer that was previously passed to
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 positive number becoming a negative number if the value is > 2^31 -1.
Non-finite number values set the result to zero.
values outside the range of
-(2^53 - 1) - (2^53 - 1) will lose precision.
Buffer to write the ISO-8859-1-encoded string into.
If NULL is passed in, the length of the string (in bytes) is returned.
Size of the destination buffer.
When this value is
insufficient, the returned string will be truncated.
Number of bytes copied into the buffer, excluding the null terminator.
This API returns the ISO-8859-1-encoded string corresponding the value passed in.
in 2-byte code units
Functions to get global instances
The value of the boolean to retrieve.
Some of these operations are documented under Section 7 of the ECMAScript Language Specification
These APIs support doing one of the following:
This API implements the abstract operation as defined in Section 7.1.2 of the ECMAScript Language Specification.
This API can be re-entrant if getters are defined on the passed-in
if the type of is not a known ECMAScript type and is not an External value.
This API represents behavior similar to invoking the Operator on the object as defined in Section 12.5.5 of the ECMAScript Language Specification.
However, it has support for detecting an External value.
If has a type that is invalid, an error is returned.
Boolean that is set to true if is true.
Whether the given object is an array.
This API checks if the passed in is an array buffer.
Whether the two objects are equal.
This API represents the invocation of the Strict Equality algorithm as defined in Section 7.2.14 of the ECMAScript Language Specification.
Some of these types are documented under Section 7 of the ECMAScript Language Specification
Fundamentally, all property keys in N-API can be represented in one of the following forms:
Named: a simple UTF8-encoded string
Integer-Indexed: an index value represented by
This can be a representing a or
N-API values are represented by the type
The APIs documented in this section provide a simple interface to
The equivalent can be done using N-API values with the following snippet:
Create a napi_value for 123
Indexed properties can be set in a similar manner.
Create a napi_value for 'hello'
Properties can be retrieved using the APIs described in this section.
The following is the approximate equivalent of the N-API counterpart:
Finally, multiple properties can also be defined on an object for performance
Create napi_values for 123 and 456
Set the properties
Used with napi_define_class to distinguish static properties from instance properties.
Ignored by napi_define_properties.
Other than they correspond to the attributes listed in Section 188.8.131.52 of the ECMAScript Language Specification.
They can be one or more of the following bitflags:
Used to indicate that no explicit attributes are set on the
By default, a property is read only, not enumerable and not
Used to indicate that a given property is writable.
Used to indicate that the property will be defined as a static property on a class as opposed to an instance property, which is the default. This is used only by
One of utf8name or name should be NULL.
Optional describing the key for the property, encoded as UTF8.
One of or must be provided for the property.
The value that's retrieved by a get access of the property if the
property is a data property.
If this is passed in, set and to (since these members won't be used).
A function to call when a get access of the property is performed.
The given function is called implicitly by the runtime when the
performed using a N-API call).