Lines Matching refs:JavaScript
10 independent from the underlying JavaScript runtime (for example, V8) and is
13 addons from 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
126 Unlike modules written in JavaScript, developing and deploying Node.js
378 exposes the actual functionality to the JavaScript environment so that the
463 of an "Agent" as a self-contained environment in which JavaScript code runs.
633 This is an opaque pointer that is used to represent a JavaScript value.
642 This is an opaque pointer that represents a JavaScript function which can be
690 JavaScript, a default handle scope will exist. If the user does not explicitly
695 of JavaScript values.
722 users to manage the lifetimes of JavaScript values, including defining their
737 with which JavaScript objects or [externals][] can be "tagged" in order to
743 type tag that had been previously applied to the JavaScript object.
785 exposed to JavaScript via Node-API. Callback functions should satisfy the
818 Since these functions may be called while the JavaScript engine is in a state
819 where it cannot execute JavaScript code, some Node-API calls may return
832 the JavaScript engine is unable to execute JavaScript, and will return
850 JavaScript or interact with JavaScript objects. Node-API calls should be in the
852 it will likely result in execution of JavaScript.
883 necessary for a call into JavaScript, usually via `napi_call_function`, and then
884 make the call into JavaScript.
887 parameter and the JavaScript function to call is given in the `js_callback`
891 sufficient to call the JavaScript function via `napi_call_function` rather than
905 * `[in] js_callback`: The JavaScript function to call, or `NULL` if the
912 the callback to convert this native data to JavaScript values (with Node-API
967 Node-API uses both return values and JavaScript exceptions for error handling.
976 no uncaught JavaScript exception was thrown. If an error occurred AND
1058 This API can be called even if there is a pending JavaScript exception.
1062 Any Node-API function call may result in a pending JavaScript exception. This is
1064 execution of JavaScript.
1077 called to allow for some minimal cleanup before returning to JavaScript.
1085 execution will return to JavaScript. As part of the transition back to
1086 JavaScript, the exception will be thrown at the point in the JavaScript
1090 JavaScript where the exception can be handled.
1098 the last JavaScript `Object` thrown. If it is determined, after
1101 JavaScript value to be thrown.
1105 of a JavaScript `Error` object: [`napi_throw_error`][],
1112 JavaScript `Error` object.
1151 * `[in] error`: The JavaScript value to be thrown.
1155 This API throws the JavaScript value provided.
1176 This API throws a JavaScript `Error` with the text provided.
1197 This API throws a JavaScript `TypeError` with the text provided.
1218 This API throws a JavaScript `RangeError` with the text provided.
1241 This API throws a JavaScript `SyntaxError` with the text provided.
1282 * `[in] msg`: `napi_value` that references a JavaScript `string` to be used as
1288 This API returns a JavaScript `Error` with the text provided.
1307 * `[in] msg`: `napi_value` that references a JavaScript `string` to be used as
1313 This API returns a JavaScript `TypeError` with the text provided.
1332 * `[in] msg`: `napi_value` that references a JavaScript `string` to be used as
1338 This API returns a JavaScript `RangeError` with the text provided.
1359 * `[in] msg`: `napi_value` that references a JavaScript `string` to be used as
1365 This API returns a JavaScript `SyntaxError` with the text provided.
1384 This API can be called even if there is a pending JavaScript exception.
1402 This API can be called even if there is a pending JavaScript exception.
1418 Trigger an `'uncaughtException'` in JavaScript. Useful if an async
1449 This API can be called even if there is a pending JavaScript exception.
1581 This API can be called even if there is a pending JavaScript exception.
1625 This API can be called even if there is a pending JavaScript exception.
1643 * `[in] escapee`: `napi_value` representing the JavaScript `Object` to be
1650 This API promotes the handle to the JavaScript object so that it is valid
1654 This API can be called even if there is a pending JavaScript exception.
1681 or the JavaScript `Symbol()` constructor calls. Globally registered symbols
1682 created with the `node_api_symbol_for` function or JavaScript `Symbol.for()`
1764 This API can be called even if there is a pending JavaScript exception.
1831 JavaScript value associated with the `napi_ref`. Otherwise, result
1967 possible with JavaScript execution disallowed, like on the request of
1969 registered `napi_finalize` callbacks of JavaScript objects, thread-safe
2091 [Working with JavaScript properties][].
2096 ## Working with JavaScript values
2098 Node-API exposes a set of APIs to create all types of JavaScript values.
2104 1. Create a new JavaScript object
2110 Any Node-API call that requires a JavaScript value takes in a `napi_value`.
2113 the `napi_value` in question is of the JavaScript type expected by the API.
2209 A JavaScript value of type `napi_external` appears in JavaScript as a plain
2248 * `[out] result`: A `napi_value` representing a JavaScript `Array`.
2252 This API returns a Node-API value corresponding to a JavaScript `Array` type.
2253 JavaScript arrays are described in
2271 * `[out] result`: A `napi_value` representing a JavaScript `Array`.
2275 This API returns a Node-API value corresponding to a JavaScript `Array` type.
2283 JavaScript arrays are described in
2304 * `[out] result`: A `napi_value` representing a JavaScript `ArrayBuffer`.
2308 This API returns a Node-API value corresponding to a JavaScript `ArrayBuffer`.
2315 written to directly from native code. To write to this buffer from JavaScript,
2318 JavaScript `ArrayBuffer` objects are described in
2392 * `[out] result`: A `napi_value` representing a JavaScript `Date`.
2399 This API allocates a JavaScript `Date` object.
2401 JavaScript `Date` objects are described in
2429 This API allocates a JavaScript value with external data attached to it. This
2430 is used to pass external data through JavaScript code, so it can be retrieved
2433 The API adds a `napi_finalize` callback which will be called when the JavaScript
2465 * `[out] result`: A `napi_value` representing a JavaScript `ArrayBuffer`.
2482 This API returns a Node-API value corresponding to a JavaScript `ArrayBuffer`.
2487 The API adds a `napi_finalize` callback which will be called when the JavaScript
2490 JavaScript `ArrayBuffer`s are described in
2512 * `[in] data`: Raw pointer to the underlying buffer to expose to JavaScript.
2538 The API adds a `napi_finalize` callback which will be called when the JavaScript
2555 * `[out] result`: A `napi_value` representing a JavaScript `Object`.
2559 This API allocates a default JavaScript `Object`.
2560 It is the equivalent of doing `new Object()` in JavaScript.
2562 The JavaScript `Object` type is described in [Section 6.1.7][] of the
2579 * `[in] description`: Optional `napi_value` which refers to a JavaScript
2581 * `[out] result`: A `napi_value` representing a JavaScript `symbol`.
2585 This API creates a JavaScript `symbol` value from a UTF8-encoded C string.
2587 The JavaScript `symbol` type is described in [Section 19.4][]
2609 * `[out] result`: A `napi_value` representing a JavaScript `symbol`.
2617 The JavaScript `symbol` type is described in [Section 19.4][] of the ECMAScript
2642 * `[out] result`: A `napi_value` representing a JavaScript `TypedArray`.
2646 This API creates a JavaScript `TypedArray` object over an existing
2655 JavaScript `TypedArray` objects are described in
2678 * `[out] result`: A `napi_value` representing a JavaScript `DataView`.
2682 This API creates a JavaScript `DataView` object over an existing `ArrayBuffer`.
2690 JavaScript `DataView` objects are described in
2707 * `[in] value`: Integer value to be represented in JavaScript.
2708 * `[out] result`: A `napi_value` representing a JavaScript `number`.
2712 This API is used to convert from the C `int32_t` type to the JavaScript
2715 The JavaScript `number` type is described in
2730 * `[in] value`: Unsigned integer value to be represented in JavaScript.
2731 * `[out] result`: A `napi_value` representing a JavaScript `number`.
2735 This API is used to convert from the C `uint32_t` type to the JavaScript
2738 The JavaScript `number` type is described in
2753 * `[in] value`: Integer value to be represented in JavaScript.
2754 * `[out] result`: A `napi_value` representing a JavaScript `number`.
2758 This API is used to convert from the C `int64_t` type to the JavaScript
2761 The JavaScript `number` type is described in [Section 6.1.6][]
2763 cannot be represented with full precision in JavaScript. Integer values
2779 * `[in] value`: Double-precision value to be represented in JavaScript.
2780 * `[out] result`: A `napi_value` representing a JavaScript `number`.
2784 This API is used to convert from the C `double` type to the JavaScript
2787 The JavaScript `number` type is described in
2804 * `[in] value`: Integer value to be represented in JavaScript.
2805 * `[out] result`: A `napi_value` representing a JavaScript `BigInt`.
2809 This API converts the C `int64_t` type to the JavaScript `BigInt` type.
2825 * `[in] value`: Unsigned integer value to be represented in JavaScript.
2826 * `[out] result`: A `napi_value` representing a JavaScript `BigInt`.
2830 This API converts the C `uint64_t` type to the JavaScript `BigInt` type.
2852 * `[out] result`: A `napi_value` representing a JavaScript `BigInt`.
2880 * `[out] result`: A `napi_value` representing a JavaScript `string`.
2884 This API creates a JavaScript `string` value from an ISO-8859-1-encoded C
2887 The JavaScript `string` type is described in
2923 doesn't need to be notified when the corresponding JavaScript string is
2927 * `[out] result`: A `napi_value` representing a JavaScript `string`.
2933 This API creates a JavaScript `string` value from an ISO-8859-1-encoded C
2935 life cycle of the JavaScript value.
2937 The JavaScript `string` type is described in
2958 * `[out] result`: A `napi_value` representing a JavaScript `string`.
2962 This API creates a JavaScript `string` value from a UTF16-LE-encoded C string.
2965 The JavaScript `string` type is described in
3001 doesn't need to be notified when the corresponding JavaScript string is
3005 * `[out] result`: A `napi_value` representing a JavaScript `string`.
3011 This API creates a JavaScript `string` value from a UTF16-LE-encoded C string.
3013 cycle of the JavaScript value.
3015 The JavaScript `string` type is described in
3036 * `[out] result`: A `napi_value` representing a JavaScript `string`.
3040 This API creates a JavaScript `string` value from a UTF8-encoded C string.
3043 The JavaScript `string` type is described in
3062 * `[in] value`: `napi_value` representing the JavaScript `Array` whose length is
3148 * `[in] object`: `napi_value` representing JavaScript `Object` whose prototype
3245 * `[in] value`: `napi_value` representing a JavaScript `Date`.
3255 This API returns the C double primitive of time value for the given JavaScript
3270 * `[in] value`: `napi_value` representing JavaScript `Boolean`.
3271 * `[out] result`: C boolean primitive equivalent of the given JavaScript
3277 This API returns the C boolean primitive equivalent of the given JavaScript
3294 * `[in] value`: `napi_value` representing JavaScript `number`.
3295 * `[out] result`: C double primitive equivalent of the given JavaScript
3301 This API returns the C double primitive equivalent of the given JavaScript
3319 * `[in] value`: `napi_value` representing JavaScript `BigInt`.
3320 * `[out] result`: C `int64_t` primitive equivalent of the given JavaScript
3328 This API returns the C `int64_t` primitive equivalent of the given JavaScript
3346 * `[in] value`: `napi_value` representing JavaScript `BigInt`.
3347 * `[out] result`: C `uint64_t` primitive equivalent of the given JavaScript
3355 This API returns the C `uint64_t` primitive equivalent of the given JavaScript
3374 * `[in] value`: `napi_value` representing JavaScript `BigInt`.
3375 * `[out] sign_bit`: Integer representing if the JavaScript `BigInt` is positive
3402 * `[in] value`: `napi_value` representing JavaScript external value.
3403 * `[out] result`: Pointer to the data wrapped by the JavaScript external value.
3425 * `[in] value`: `napi_value` representing JavaScript `number`.
3426 * `[out] result`: C `int32` primitive equivalent of the given JavaScript
3433 of the given JavaScript `number`.
3456 * `[in] value`: `napi_value` representing JavaScript `number`.
3457 * `[out] result`: C `int64` primitive equivalent of the given JavaScript
3463 This API returns the C `int64` primitive equivalent of the given JavaScript
3489 * `[in] value`: `napi_value` representing JavaScript string.
3520 * `[in] value`: `napi_value` representing JavaScript string.
3550 * `[in] value`: `napi_value` representing JavaScript string.
3578 * `[in] value`: `napi_value` representing JavaScript `number`.
3603 * `[out] result`: `napi_value` representing JavaScript `Boolean` singleton to
3608 This API is used to return the JavaScript singleton object that is used to
3623 * `[out] result`: `napi_value` representing JavaScript `global` object.
3641 * `[out] result`: `napi_value` representing JavaScript `null` object.
3659 * `[out] result`: `napi_value` representing JavaScript Undefined value.
3665 ## Working with JavaScript values and abstract operations
3667 Node-API exposes a set of APIs to perform some abstract operations on JavaScript
3673 1. Coerce JavaScript values to specific JavaScript types (such as `number` or
3675 2. Check the type of a JavaScript value.
3676 3. Check for equality between two JavaScript values.
3692 * `[in] value`: The JavaScript value to coerce.
3693 * `[out] result`: `napi_value` representing the coerced JavaScript `Boolean`.
3714 * `[in] value`: The JavaScript value to coerce.
3715 * `[out] result`: `napi_value` representing the coerced JavaScript `number`.
3738 * `[in] value`: The JavaScript value to coerce.
3739 * `[out] result`: `napi_value` representing the coerced JavaScript `Object`.
3760 * `[in] value`: The JavaScript value to coerce.
3761 * `[out] result`: `napi_value` representing the coerced JavaScript `string`.
3782 * `[in] value`: The JavaScript value whose type to query.
3783 * `[out] result`: The type of the JavaScript value.
3815 * `[in] object`: The JavaScript value to check.
3816 * `[in] constructor`: The JavaScript function object of the constructor function
3838 * `[in] value`: The JavaScript value to check.
3858 * `[in] value`: The JavaScript value to check.
3877 * `[in] value`: The JavaScript value to check.
3899 * `[in] value`: The JavaScript value to check.
3900 * `[out] result`: Whether the given `napi_value` represents a JavaScript `Date`
3919 * `[in] value`: The JavaScript value to check.
3938 * `[in] value`: The JavaScript value to check.
3957 * `[in] value`: The JavaScript value to check.
3979 * `[in] lhs`: The JavaScript value to check.
3980 * `[in] rhs`: The JavaScript value to check against.
4004 * `[in] arraybuffer`: The JavaScript `ArrayBuffer` to be detached.
4034 * `[in] arraybuffer`: The JavaScript `ArrayBuffer` to be checked.
4045 ## Working with JavaScript properties
4047 Node-API exposes a set of APIs to get and set properties on JavaScript
4051 Properties in JavaScript are represented as a tuple of a key and a value.
4057 * JavaScript value: these are represented in Node-API by `napi_value`. This can
4061 Any Node-API call that requires a JavaScript value takes in a `napi_value`.
4063 `napi_value` in question is of the JavaScript type expected by the API.
4066 get and set properties on arbitrary JavaScript objects represented by
4069 For instance, consider the following JavaScript code snippet:
4096 JavaScript snippet:
4123 Consider the following JavaScript snippet:
4146 reasons. Consider the following JavaScript:
4218 set on a JavaScript object. Other than `napi_static` they correspond to the
4234 * `napi_default_jsproperty`: Like a property set via assignment in JavaScript,
4258 * `name`: Optional `napi_value` that points to a JavaScript string or symbol
4267 the property is accessed from JavaScript code (or if a get on the property is
4272 the property is set from JavaScript code (or if a set on the property is
4275 property to be a JavaScript function represented by `method`. If this is
4300 * `[out] result`: A `napi_value` representing an array of JavaScript values
4336 * `[out] result`: A `napi_value` representing an array of JavaScript values
4708 ## Working with JavaScript functions
4710 Node-API provides a set of APIs that allow JavaScript code to
4713 the `napi_callback` type. When the JavaScript VM calls back to
4723 JavaScript functions from native code. One can either call a function
4724 like a regular JavaScript function call, or as a constructor
4750 * `[in] func`: `napi_value` representing the JavaScript function to be invoked.
4752 * `[in] argv`: Array of `napi_values` representing JavaScript values passed in
4754 * `[out] result`: `napi_value` representing the JavaScript object returned.
4758 This method allows a JavaScript function object to be called from a native
4760 native code _into_ JavaScript. For the special case of calling into JavaScript
4763 A sample use case might look as follows. Consider the following JavaScript
4821 visible within JavaScript as the new function object's `name` property.
4828 * `[out] result`: `napi_value` representing the JavaScript function object for
4835 _from_ JavaScript.
4839 to JavaScript, in order for the function to be accessible from script.
4867 Given the above code, the add-on can be used from JavaScript as follows:
4878 be associated with the resulting JavaScript function (which is returned in the
4880 passing both the JavaScript function and the data to [`napi_add_finalizer`][].
4882 JavaScript `Function`s are described in [Section 19.2][] of the ECMAScript
4912 * `[out] thisArg`: Receives the JavaScript `this` argument for the call.
4960 * `[in] cons`: `napi_value` representing the JavaScript function to be invoked
4963 * `[in] argv`: Array of JavaScript values as `napi_value` representing the
4966 * `[out] result`: `napi_value` representing the JavaScript object returned,
4969 This method is used to instantiate a new JavaScript value using a given
5009 constructor and methods can be called from JavaScript.
5011 1. The [`napi_define_class`][] API defines a JavaScript class with constructor,
5014 2. When JavaScript code invokes the constructor, the constructor callback
5015 uses [`napi_wrap`][] to wrap a new C++ instance in a JavaScript object,
5017 3. When JavaScript code invokes a method or property accessor on the class,
5044 a JavaScript object is a wrapper for a certain native type. This is the case
5045 especially when wrapped JavaScript objects are passed back into the addon via
5052 // `openDatabase()` returns a JavaScript object that wraps a native database
5056 // `query()` returns a JavaScript object that wraps a native query handle.
5082 `queryHasRecords()` has to perform a type validation. Retaining the JavaScript
5099 along with a JavaScript object or [external][] stored in a `napi_value` to
5100 `napi_type_tag_object()`, the JavaScript object will be "marked" with the
5101 type tag. The "mark" is invisible on the JavaScript side. When a JavaScript
5103 along with the original type tag to determine whether the JavaScript object was
5150 // Later when we receive a JavaScript object purporting to be a database handle
5199 * `[in] utf8name`: Name of the JavaScript constructor function. For clarity,
5218 Defines a JavaScript class, including:
5220 * A JavaScript constructor function that has the class name. When wrapping a
5223 JavaScript object instance being constructed using [`napi_wrap`][].
5231 instance placed inside the JavaScript object instance by using
5236 then wraps the new C++ instance in a JavaScript object, and returns the wrapper
5239 The JavaScript constructor function returned from [`napi_define_class`][] is
5248 with the resulting JavaScript constructor (which is returned in the `result`
5250 the JavaScript function and the data to [`napi_add_finalizer`][].
5269 * `[in] js_object`: The JavaScript object that will be the wrapper for the
5272 JavaScript object.
5274 native instance when the JavaScript object has been garbage-collected.
5282 Wraps a native instance in a JavaScript object. The native instance can be
5285 When JavaScript code invokes a constructor for a class that was defined using
5289 JavaScript object that is the `this` argument to the constructor callback.
5335 Retrieves a native instance that was previously wrapped in a JavaScript
5338 When JavaScript code invokes a method or property accessor on the class, the
5363 Retrieves a native instance that was previously wrapped in the JavaScript
5366 JavaScript object becomes garbage-collected.
5384 * `[in] js_object`: The JavaScript object or [external][] to be marked.
5389 Associates the value of the `type_tag` pointer with the JavaScript object or
5414 * `[in] js_object`: The JavaScript object or [external][] whose type tag to
5444 * `[in] js_object`: The JavaScript object to which the native data will be
5448 native data when the JavaScript object has been garbage-collected.
5452 * `[out] result`: Optional reference to the JavaScript object.
5456 Adds a `napi_finalize` callback which will be called when the JavaScript object
5459 This API can be called multiple times on a single JavaScript object.
5486 that could result in the execution of JavaScript or interaction with
5487 JavaScript objects. Most often, any code that needs to make Node-API
5490 it will likely execute JavaScript.
5592 This API can be called even if there is a pending JavaScript exception.
5639 This API can be called even if there is a pending JavaScript exception.
5677 garbage collected by JavaScript engine before the `napi_async_context` was
5706 This API can be called even if there is a pending JavaScript exception.
5738 * `[in] func`: `napi_value` representing the JavaScript function to be invoked.
5740 * `[in] argv`: Array of JavaScript values as `napi_value` representing the
5743 * `[out] result`: `napi_value` representing the JavaScript object returned.
5747 This method allows a JavaScript function object to be called from a native
5749 _from_ native code back _into_ JavaScript _after_ returning from an async
5761 JavaScript during the callback are ran before returning back to C/C++.
5808 This API can be called even if there is a pending JavaScript exception.
5890 alive by JavaScript objects.
5896 memory that is kept alive by JavaScript objects (i.e. a JavaScript object
5911 be returned to JavaScript where it can be used in the usual fashion.
5974 * `[out] promise`: The JavaScript promise associated with the deferred object.
5978 This API creates a deferred object and a JavaScript promise.
5997 This API resolves a JavaScript promise by way of the deferred object
5998 with which it is associated. Thus, it can only be used to resolve JavaScript
6023 This API rejects a JavaScript promise by way of the deferred object
6024 with which it is associated. Thus, it can only be used to reject JavaScript
6052 Node-API provides an API for executing a string containing JavaScript using the
6053 underlying JavaScript engine.
6069 * `[in] script`: A JavaScript string containing the script to execute.
6072 This function executes a string of JavaScript code and returns its result with
6109 JavaScript functions can normally only be called from a native addon's main
6114 When an addon has additional threads and JavaScript functions need to be invoked
6117 JavaScript function on their behalf. The thread-safe function APIs provide an
6123 `napi_value` that holds a JavaScript function which can be called from multiple
6125 JavaScript callback is to be called will be placed in a queue, and, for each
6126 value in the queue, a call will eventually be made to the JavaScript function.
6143 JavaScript. `napi_call_threadsafe_function()` accepts a parameter which controls
6152 from a JavaScript thread, because, if the queue is full, it may cause the
6153 JavaScript thread to deadlock.
6155 The actual call into JavaScript is controlled by the callback given via the
6159 callback will be used, and the resulting JavaScript call will have no arguments.
6160 The `call_js_cb` callback receives the JavaScript function to call as a
6164 as `napi_call_function()` to call into JavaScript.
6167 to indicate that calls into JavaScript are no longer possible, while items
6171 It is not necessary to call into JavaScript via `napi_make_callback()` because
6265 * `[in] func`: An optional JavaScript function to call from another thread. It
6269 * `[in] async_resource_name`: A JavaScript string to provide an identifier for
6281 * `[in] call_js_cb`: Optional callback which calls the JavaScript function in
6283 main thread. If not given, the JavaScript function will be called with no
6286 * `[out] result`: The asynchronous thread-safe JavaScript function.
6329 * `[in] func`: The asynchronous thread-safe JavaScript function to invoke.
6330 * `[in] data`: Data to send into JavaScript via the callback `call_js_cb`
6331 provided during the creation of the thread-safe JavaScript function.
6337 This API should not be called with `napi_tsfn_blocking` from a JavaScript
6338 thread, because, if the queue is full, it may cause the JavaScript thread to
6359 * `[in] func`: The asynchronous thread-safe JavaScript function to start making
6382 * `[in] func`: The asynchronous thread-safe JavaScript function whose reference
6516 [Working with JavaScript properties]: #working-with-javascript-properties