Lines Matching refs:JavaScript
10 the underlying JavaScript runtime (for example, V8) and is maintained as part of
13 changes in the underlying JavaScript engine and allow modules
23 JavaScript values. Concepts and operations generally map to ideas specified
30 * All JavaScript values are abstracted behind an opaque type named
125 Unlike modules written in JavaScript, developing and deploying Node.js
280 exposes the actual functionality to the JavaScript environment so that the
364 of an "Agent" as a self-contained environment in which JavaScript code runs.
522 This is an opaque pointer that is used to represent a JavaScript value.
530 This is an opaque pointer that represents a JavaScript function which can be
575 JavaScript, a default handle scope will exist. If the user does not explicitly
580 of JavaScript values.
603 users to manage the lifetimes of JavaScript values, including defining their
614 with which JavaScript objects can be "tagged" in order to ensure that they are
620 previously applied to the JavaScript object.
655 exposed to JavaScript via N-API. Callback functions should satisfy the
699 JavaScript or interact with JavaScript objects. N-API calls should be in the
701 it will likely result in execution of JavaScript.
729 necessary for a call into JavaScript, usually via `napi_call_function`, and then
730 make the call into JavaScript.
733 parameter and the JavaScript function to call is given in the `js_callback`
737 sufficient to call the JavaScript function via `napi_call_function` rather than
751 * `[in] js_callback`: The JavaScript function to call, or `NULL` if the
758 the callback to convert this native data to JavaScript values (with N-API
792 N-API uses both return values and JavaScript exceptions for error handling.
801 no uncaught JavaScript exception was thrown. If an error occurred AND
877 This API can be called even if there is a pending JavaScript exception.
881 Any N-API function call may result in a pending JavaScript exception. This is
883 execution of JavaScript.
896 called to allow for some minimal cleanup before returning to JavaScript.
904 execution will return to JavaScript. As part of the transition back to
905 JavaScript, the exception will be thrown at the point in the JavaScript
909 JavaScript where the exception can be handled.
917 the last JavaScript `Object` thrown. If it is determined, after
920 JavaScript `Error` object to be thrown.
924 of a JavaScript `Error` object: [`napi_throw_error`][],
932 JavaScript `Error` object.
970 * `[in] error`: The JavaScript value to be thrown.
974 This API throws the JavaScript value provided.
994 This API throws a JavaScript `Error` with the text provided.
1014 This API throws a JavaScript `TypeError` with the text provided.
1034 This API throws a JavaScript `RangeError` with the text provided.
1073 * `[in] msg`: `napi_value` that references a JavaScript `String` to be used as
1079 This API returns a JavaScript `Error` with the text provided.
1097 * `[in] msg`: `napi_value` that references a JavaScript `String` to be used as
1103 This API returns a JavaScript `TypeError` with the text provided.
1121 * `[in] msg`: `napi_value` that references a JavaScript `String` to be used as
1127 This API returns a JavaScript `RangeError` with the text provided.
1145 This API can be called even if there is a pending JavaScript exception.
1162 This API can be called even if there is a pending JavaScript exception.
1177 Trigger an `'uncaughtException'` in JavaScript. Useful if an async
1207 This API can be called even if there is a pending JavaScript exception.
1336 This API can be called even if there is a pending JavaScript exception.
1378 This API can be called even if there is a pending JavaScript exception.
1395 * `[in] escapee`: `napi_value` representing the JavaScript `Object` to be
1402 This API promotes the handle to the JavaScript object so that it is valid
1406 This API can be called even if there is a pending JavaScript exception.
1488 This API can be called even if there is a pending JavaScript exception.
1555 JavaScript `Object` associated with the `napi_ref`. Otherwise, result
1793 [Working with JavaScript properties][].
1798 ## Working with JavaScript values
1799 N-API exposes a set of APIs to create all types of JavaScript values.
1805 1. Create a new JavaScript object
1811 Any N-API call that requires a JavaScript value takes in a `napi_value`.
1814 the `napi_value` in question is of the JavaScript type expected by the API.
1897 A JavaScript value of type `napi_external` appears in JavaScript as a plain
1934 * `[out] result`: A `napi_value` representing a JavaScript `Array`.
1938 This API returns an N-API value corresponding to a JavaScript `Array` type.
1939 JavaScript arrays are described in
1956 * `[out] result`: A `napi_value` representing a JavaScript `Array`.
1960 This API returns an N-API value corresponding to a JavaScript `Array` type.
1968 JavaScript arrays are described in
1987 * `[out] result`: A `napi_value` representing a JavaScript `ArrayBuffer`.
1991 This API returns an N-API value corresponding to a JavaScript `ArrayBuffer`.
1998 written to directly from native code. To write to this buffer from JavaScript,
2001 JavaScript `ArrayBuffer` objects are described in
2068 * `[out] result`: A `napi_value` representing a JavaScript `Date`.
2075 This API allocates a JavaScript `Date` object.
2077 JavaScript `Date` objects are described in
2104 This API allocates a JavaScript value with external data attached to it. This
2105 is used to pass external data through JavaScript code, so it can be retrieved
2108 The API adds a `napi_finalize` callback which will be called when the JavaScript
2144 * `[out] result`: A `napi_value` representing a JavaScript `ArrayBuffer`.
2148 This API returns an N-API value corresponding to a JavaScript `ArrayBuffer`.
2153 The API adds a `napi_finalize` callback which will be called when the JavaScript
2161 JavaScript `ArrayBuffer`s are described in
2182 * `[in] data`: Raw pointer to the underlying buffer to expose to JavaScript.
2195 The API adds a `napi_finalize` callback which will be called when the JavaScript
2216 * `[out] result`: A `napi_value` representing a JavaScript `Object`.
2220 This API allocates a default JavaScript `Object`.
2221 It is the equivalent of doing `new Object()` in JavaScript.
2223 The JavaScript `Object` type is described in [Section 6.1.7][] of the
2239 * `[in] description`: Optional `napi_value` which refers to a JavaScript
2241 * `[out] result`: A `napi_value` representing a JavaScript `Symbol`.
2245 This API creates a JavaScript `Symbol` object from a UTF8-encoded C string.
2247 The JavaScript `Symbol` type is described in [Section 19.4][]
2271 * `[out] result`: A `napi_value` representing a JavaScript `TypedArray`.
2275 This API creates a JavaScript `TypedArray` object over an existing
2284 JavaScript `TypedArray` objects are described in
2306 * `[out] result`: A `napi_value` representing a JavaScript `DataView`.
2310 This API creates a JavaScript `DataView` object over an existing `ArrayBuffer`.
2318 JavaScript `DataView` objects are described in
2333 * `[in] value`: Integer value to be represented in JavaScript.
2334 * `[out] result`: A `napi_value` representing a JavaScript `Number`.
2338 This API is used to convert from the C `int32_t` type to the JavaScript
2341 The JavaScript `Number` type is described in
2355 * `[in] value`: Unsigned integer value to be represented in JavaScript.
2356 * `[out] result`: A `napi_value` representing a JavaScript `Number`.
2360 This API is used to convert from the C `uint32_t` type to the JavaScript
2363 The JavaScript `Number` type is described in
2377 * `[in] value`: Integer value to be represented in JavaScript.
2378 * `[out] result`: A `napi_value` representing a JavaScript `Number`.
2382 This API is used to convert from the C `int64_t` type to the JavaScript
2385 The JavaScript `Number` type is described in [Section 6.1.6][]
2387 cannot be represented with full precision in JavaScript. Integer values
2402 * `[in] value`: Double-precision value to be represented in JavaScript.
2403 * `[out] result`: A `napi_value` representing a JavaScript `Number`.
2407 This API is used to convert from the C `double` type to the JavaScript
2410 The JavaScript `Number` type is described in
2426 * `[in] value`: Integer value to be represented in JavaScript.
2427 * `[out] result`: A `napi_value` representing a JavaScript `BigInt`.
2431 This API converts the C `int64_t` type to the JavaScript `BigInt` type.
2446 * `[in] value`: Unsigned integer value to be represented in JavaScript.
2447 * `[out] result`: A `napi_value` representing a JavaScript `BigInt`.
2451 This API converts the C `uint64_t` type to the JavaScript `BigInt` type.
2472 * `[out] result`: A `napi_value` representing a JavaScript `BigInt`.
2499 * `[out] result`: A `napi_value` representing a JavaScript `String`.
2503 This API creates a JavaScript `String` object from an ISO-8859-1-encoded C
2506 The JavaScript `String` type is described in
2526 * `[out] result`: A `napi_value` representing a JavaScript `String`.
2530 This API creates a JavaScript `String` object from a UTF16-LE-encoded C string.
2533 The JavaScript `String` type is described in
2553 * `[out] result`: A `napi_value` representing a JavaScript `String`.
2557 This API creates a JavaScript `String` object from a UTF8-encoded C string.
2560 The JavaScript `String` type is described in
2577 * `[in] value`: `napi_value` representing the JavaScript `Array` whose length is
2660 * `[in] object`: `napi_value` representing JavaScript `Object` whose prototype
2748 * `[in] value`: `napi_value` representing a JavaScript `Date`.
2758 This API returns the C double primitive of time value for the given JavaScript
2772 * `[in] value`: `napi_value` representing JavaScript `Boolean`.
2773 * `[out] result`: C boolean primitive equivalent of the given JavaScript
2779 This API returns the C boolean primitive equivalent of the given JavaScript
2795 * `[in] value`: `napi_value` representing JavaScript `Number`.
2796 * `[out] result`: C double primitive equivalent of the given JavaScript
2802 This API returns the C double primitive equivalent of the given JavaScript
2819 * `[in] value`: `napi_value` representing JavaScript `BigInt`.
2820 * `[out] result`: C `int64_t` primitive equivalent of the given JavaScript
2828 This API returns the C `int64_t` primitive equivalent of the given JavaScript
2845 * `[in] value`: `napi_value` representing JavaScript `BigInt`.
2846 * `[out] result`: C `uint64_t` primitive equivalent of the given JavaScript
2854 This API returns the C `uint64_t` primitive equivalent of the given JavaScript
2872 * `[in] value`: `napi_value` representing JavaScript `BigInt`.
2873 * `[out] sign_bit`: Integer representing if the JavaScript `BigInt` is positive
2899 * `[in] value`: `napi_value` representing JavaScript external value.
2900 * `[out] result`: Pointer to the data wrapped by the JavaScript external value.
2921 * `[in] value`: `napi_value` representing JavaScript `Number`.
2922 * `[out] result`: C `int32` primitive equivalent of the given JavaScript
2929 of the given JavaScript `Number`.
2951 * `[in] value`: `napi_value` representing JavaScript `Number`.
2952 * `[out] result`: C `int64` primitive equivalent of the given JavaScript
2958 This API returns the C `int64` primitive equivalent of the given JavaScript
2983 * `[in] value`: `napi_value` representing JavaScript string.
3012 * `[in] value`: `napi_value` representing JavaScript string.
3040 * `[in] value`: `napi_value` representing JavaScript string.
3066 * `[in] value`: `napi_value` representing JavaScript `Number`.
3089 * `[out] result`: `napi_value` representing JavaScript `Boolean` singleton to
3094 This API is used to return the JavaScript singleton object that is used to
3108 * `[out] result`: `napi_value` representing JavaScript `global` object.
3125 * `[out] result`: `napi_value` representing JavaScript `null` object.
3142 * `[out] result`: `napi_value` representing JavaScript Undefined value.
3148 ## Working with JavaScript values and abstract operations
3150 N-API exposes a set of APIs to perform some abstract operations on JavaScript
3156 1. Coerce JavaScript values to specific JavaScript types (such as `Number` or
3158 2. Check the type of a JavaScript value.
3159 3. Check for equality between two JavaScript values.
3174 * `[in] value`: The JavaScript value to coerce.
3175 * `[out] result`: `napi_value` representing the coerced JavaScript `Boolean`.
3196 * `[in] value`: The JavaScript value to coerce.
3197 * `[out] result`: `napi_value` representing the coerced JavaScript `Number`.
3218 * `[in] value`: The JavaScript value to coerce.
3219 * `[out] result`: `napi_value` representing the coerced JavaScript `Object`.
3240 * `[in] value`: The JavaScript value to coerce.
3241 * `[out] result`: `napi_value` representing the coerced JavaScript `String`.
3260 * `[in] value`: The JavaScript value whose type to query.
3261 * `[out] result`: The type of the JavaScript value.
3292 * `[in] object`: The JavaScript value to check.
3293 * `[in] constructor`: The JavaScript function object of the constructor function
3314 * `[in] value`: The JavaScript value to check.
3333 * `[in] value`: The JavaScript value to check.
3351 * `[in] value`: The JavaScript value to check.
3370 * `[in] value`: The JavaScript value to check.
3371 * `[out] result`: Whether the given `napi_value` represents a JavaScript `Date`
3389 * `[in] value`: The JavaScript value to check.
3407 * `[in] value`: The JavaScript value to check.
3425 * `[in] value`: The JavaScript value to check.
3446 * `[in] lhs`: The JavaScript value to check.
3447 * `[in] rhs`: The JavaScript value to check against.
3467 * `[in] arraybuffer`: The JavaScript `ArrayBuffer` to be detached.
3493 * `[in] arraybuffer`: The JavaScript `ArrayBuffer` to be checked.
3504 ## Working with JavaScript properties
3506 N-API exposes a set of APIs to get and set properties on JavaScript
3510 Properties in JavaScript are represented as a tuple of a key and a value.
3516 * JavaScript value: these are represented in N-API by `napi_value`. This can
3520 Any N-API call that requires a JavaScript value takes in a `napi_value`.
3522 `napi_value` in question is of the JavaScript type expected by the API.
3525 get and set properties on arbitrary JavaScript objects represented by
3528 For instance, consider the following JavaScript code snippet:
3555 JavaScript snippet:
3582 Consider the following JavaScript snippet:
3605 reasons. Consider the following JavaScript:
3675 set on a JavaScript object. Other than `napi_static` they correspond to the
3715 * `name`: Optional `napi_value` that points to a JavaScript string or symbol
3724 the property is accessed from JavaScript code (or if a get on the property is
3729 the property is set from JavaScript code (or if a set on the property is
3732 property to be a JavaScript function represented by `method`. If this is
3755 * `[out] result`: A `napi_value` representing an array of JavaScript values
3787 * `[out] result`: A `napi_value` representing an array of JavaScript values
4142 ## Working with JavaScript functions
4144 N-API provides a set of APIs that allow JavaScript code to
4147 the `napi_callback` type. When the JavaScript VM calls back to
4157 JavaScript functions from native code. One can either call a function
4158 like a regular JavaScript function call, or as a constructor
4183 * `[in] func`: `napi_value` representing the JavaScript function to be invoked.
4185 * `[in] argv`: Array of `napi_values` representing JavaScript values passed in
4187 * `[out] result`: `napi_value` representing the JavaScript object returned.
4191 This method allows a JavaScript function object to be called from a native
4193 native code *into* JavaScript. For the special case of calling into JavaScript
4196 A sample use case might look as follows. Consider the following JavaScript
4252 within JavaScript as the new function object's `name` property.
4259 * `[out] result`: `napi_value` representing the JavaScript function object for
4266 *from* JavaScript.
4270 to JavaScript, in order for the function to be accessible from script.
4298 Given the above code, the add-on can be used from JavaScript as follows:
4309 be associated with the resulting JavaScript function (which is returned in the
4311 passing both the JavaScript function and the data to [`napi_add_finalizer`][].
4313 JavaScript `Function`s are described in [Section 19.2][] of the ECMAScript
4340 * `[out] this`: Receives the JavaScript `this` argument for the call.
4384 * `[in] cons`: `napi_value` representing the JavaScript function to be invoked
4387 * `[in] argv`: Array of JavaScript values as `napi_value` representing the
4389 * `[out] result`: `napi_value` representing the JavaScript object returned,
4392 This method is used to instantiate a new JavaScript value using a given
4432 constructor and methods can be called from JavaScript.
4434 1. The [`napi_define_class`][] API defines a JavaScript class with constructor,
4437 2. When JavaScript code invokes the constructor, the constructor callback
4438 uses [`napi_wrap`][] to wrap a new C++ instance in a JavaScript object,
4440 3. When JavaScript code invokes a method or property accessor on the class,
4467 a JavaScript object is a wrapper for a certain native type. This is the case
4468 especially when wrapped JavaScript objects are passed back into the addon via
4475 // `openDatabase()` returns a JavaScript object that wraps a native database
4479 // `query()` returns a JavaScript object that wraps a native query handle.
4505 `queryHasRecords()` has to perform a type validation. Retaining the JavaScript
4522 along with a JavaScript object stored in a `napi_value` to
4523 `napi_type_tag_object()`, the JavaScript object will be "marked" with the
4524 type tag. The "mark" is invisible on the JavaScript side. When a JavaScript
4526 along with the original type tag to determine whether the JavaScript object was
4573 // Later when we receive a JavaScript object purporting to be a database handle
4621 * `[in] utf8name`: Name of the JavaScript constructor function; this is
4640 Defines a JavaScript class that corresponds to a C++ class, including:
4642 * A JavaScript constructor function that has the class name and invokes the
4652 the actual class constructor, then wraps the new C++ instance in a JavaScript
4655 The JavaScript constructor function returned from [`napi_define_class`][] is
4664 with the resulting JavaScript constructor (which is returned in the `result`
4666 the JavaScript function and the data to [`napi_add_finalizer`][].
4684 * `[in] js_object`: The JavaScript object that will be the wrapper for the
4687 JavaScript object.
4689 native instance when the JavaScript object is ready for garbage-collection.
4697 Wraps a native instance in a JavaScript object. The native instance can be
4700 When JavaScript code invokes a constructor for a class that was defined using
4704 JavaScript object that is the `this` argument to the constructor callback.
4744 Retrieves a native instance that was previously wrapped in a JavaScript
4747 When JavaScript code invokes a method or property accessor on the class, the
4771 Retrieves a native instance that was previously wrapped in the JavaScript
4774 JavaScript object becomes garbage-collected.
4790 * `[in] js_object`: The JavaScript object to be marked.
4795 Associates the value of the `type_tag` pointer with the JavaScript object.
4818 * `[in] js_object`: The JavaScript object whose type tag to examine.
4847 * `[in] js_object`: The JavaScript object to which the native data will be
4849 * `[in] native_object`: The native data that will be attached to the JavaScript
4852 native data when the JavaScript object is ready for garbage-collection.
4856 * `[out] result`: Optional reference to the JavaScript object.
4860 Adds a `napi_finalize` callback which will be called when the JavaScript object
4867 attach each of them to the JavaScript object, and
4895 that could result in the execution of JavaScript or interaction with
4896 JavaScript objects. Most often, any code that needs to make N-API
4899 it will likely execute JavaScript.
4999 This API can be called even if there is a pending JavaScript exception.
5044 This API can be called even if there is a pending JavaScript exception.
5097 This API can be called even if there is a pending JavaScript exception.
5125 * `[in] func`: `napi_value` representing the JavaScript function to be invoked.
5127 * `[in] argv`: Array of JavaScript values as `napi_value` representing the
5129 * `[out] result`: `napi_value` representing the JavaScript object returned.
5133 This method allows a JavaScript function object to be called from a native
5135 *from* native code back *into* JavaScript *after* returning from an async
5147 JavaScript during the callback are ran before returning back to C/C++.
5190 This API can be called even if there is a pending JavaScript exception.
5269 alive by JavaScript objects.
5275 memory that is kept alive by JavaScript objects (i.e. a JavaScript object
5290 be returned to JavaScript where it can be used in the usual fashion.
5352 * `[out] promise`: The JavaScript promise associated with the deferred object.
5356 This API creates a deferred object and a JavaScript promise.
5374 This API resolves a JavaScript promise by way of the deferred object
5375 with which it is associated. Thus, it can only be used to resolve JavaScript
5399 This API rejects a JavaScript promise by way of the deferred object
5400 with which it is associated. Thus, it can only be used to reject JavaScript
5427 N-API provides an API for executing a string containing JavaScript using the
5428 underlying JavaScript engine.
5443 * `[in] script`: A JavaScript string containing the script to execute.
5446 This function executes a string of JavaScript code and returns its result with
5482 JavaScript functions can normally only be called from a native addon's main
5487 When an addon has additional threads and JavaScript functions need to be invoked
5490 JavaScript function on their behalf. The thread-safe function APIs provide an
5496 `napi_value` that holds a JavaScript function which can be called from multiple
5498 JavaScript callback is to be called will be placed in a queue, and, for each
5499 value in the queue, a call will eventually be made to the JavaScript function.
5516 JavaScript. `napi_call_threadsafe_function()` accepts a parameter which controls
5524 The actual call into JavaScript is controlled by the callback given via the
5528 callback will be used, and the resulting JavaScript call will have no arguments.
5529 The `call_js_cb` callback receives the JavaScript function to call as a
5533 as `napi_call_function()` to call into JavaScript.
5536 to indicate that calls into JavaScript are no longer possible, while items
5540 It is not necessary to call into JavaScript via `napi_make_callback()` because
5627 * `[in] func`: An optional JavaScript function to call from another thread. It
5631 * `[in] async_resource_name`: A JavaScript string to provide an identifier for
5643 * `[in] call_js_cb`: Optional callback which calls the JavaScript function in
5645 main thread. If not given, the JavaScript function will be called with no
5648 * `[out] result`: The asynchronous thread-safe JavaScript function.
5682 * `[in] func`: The asynchronous thread-safe JavaScript function to invoke.
5683 * `[in] data`: Data to send into JavaScript via the callback `call_js_cb`
5684 provided during the creation of the thread-safe JavaScript function.
5708 * `[in] func`: The asynchronous thread-safe JavaScript function to start making
5731 * `[in] func`: The asynchronous thread-safe JavaScript function whose reference
5837 [Working with JavaScript properties]: #n_api_working_with_javascript_properties