GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — doc: explain napi_run_script · nodejs/node@5537fae

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • doc/api
    • n-api.md
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎doc/api/n-api.md‎

Copy file name to clipboardExpand all lines: doc/api/n-api.md
+16Lines changed: 16 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -4904,6 +4904,19 @@ NAPI_EXTERN napi_status napi_run_script(napi_env env,
49044904
* `[in] script`: A JavaScript string containing the script to execute.
49054905
* `[out] result`: The value resulting from having executed the script.
49064906

4907+
This function executes a string of JavaScript code and returns its result with
4908+
the following caveats:
4909+
4910+
* Unlike `eval`, this function does not allow the script to access the current
4911+
lexical scope, and therefore also does not allow to access the
4912+
[module scope][], meaning that pseudo-globals such as `require` will not be
4913+
available.
4914+
* The script can access the [global scope][]. Function and `var` declarations
4915+
in the script will be added to the [`global`][] object. Variable declarations
4916+
made using `let` and `const` will be visible globally, but will not be added
4917+
to the [`global`][] object.
4918+
* The value of `this` is [`global`][] within the script.
4919+
49074920
## libuv event loop
49084921

49094922
N-API provides a function for getting the current event loop associated with
@@ -5265,6 +5278,7 @@ This API may only be called from the main thread.
52655278
[Xcode]: https://developer.apple.com/xcode/
52665279
[`Number.MAX_SAFE_INTEGER`]: https://tc39.github.io/ecma262/#sec-number.max_safe_integer
52675280
[`Number.MIN_SAFE_INTEGER`]: https://tc39.github.io/ecma262/#sec-number.min_safe_integer
5281+
[`global`]: globals.html#globals_global
52685282
[`init` hooks]: async_hooks.html#async_hooks_init_asyncid_type_triggerasyncid_resource
52695283
[`napi_add_finalizer`]: #n_api_napi_add_finalizer
52705284
[`napi_async_init`]: #n_api_napi_async_init
@@ -5315,6 +5329,8 @@ This API may only be called from the main thread.
53155329
[async_hooks `type`]: async_hooks.html#async_hooks_type
53165330
[context-aware addons]: addons.html#addons_context_aware_addons
53175331
[docs]: https://github.com/nodejs/node-addon-api#api-documentation
5332+
[global scope]: globals.html
5333+
[module scope]: modules.html#modules_the_module_scope
53185334
[node-addon-api]: https://github.com/nodejs/node-addon-api
53195335
[node-gyp]: https://github.com/nodejs/node-gyp
53205336
[node-pre-gyp]: https://github.com/mapbox/node-pre-gyp

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.