Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/doc/api
diff options
context:
space:
mode:
authorAntoine du HAMEL <duhamelantoine1995@gmail.com>2020-02-06 18:08:07 +0300
committerAnna Henningsen <anna@addaleax.net>2020-03-13 12:50:30 +0300
commita8b3d7b26b8be875a60cf3b137e6614f1fc8bffb (patch)
treed110d0c390c9fa73c79382b0211f4f4cf2dca4c5 /doc/api
parent04028aac3a59548a57f4c79b03b9e8a0c6b4b25d (diff)
worker: allow URL in Worker constructor
The explicit goal is to let users use `import.meta.url` to re-load thecurrent module inside a Worker instance. Fixes: https://github.com/nodejs/node/issues/30780 PR-URL: https://github.com/nodejs/node/pull/31664 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Diffstat (limited to 'doc/api')
-rw-r--r--doc/api/worker_threads.md16
1 files changed, 11 insertions, 5 deletions
diff --git a/doc/api/worker_threads.md b/doc/api/worker_threads.md
index 406728995c9..ca42643969a 100644
--- a/doc/api/worker_threads.md
+++ b/doc/api/worker_threads.md
@@ -513,6 +513,10 @@ if (isMainThread) {
<!-- YAML
added: v10.5.0
changes:
+ - version: REPLACEME
+ pr-url: https://github.com/nodejs/node/pull/31664
+ description: The `filename` parameter can be a WHATWG `URL` object using
+ `file:` protocol.
- version: v13.2.0
pr-url: https://github.com/nodejs/node/pull/26628
description: The `resourceLimits` option was introduced.
@@ -521,9 +525,10 @@ changes:
description: The `argv` option was introduced.
-->
-* `filename` {string} The path to the Worker’s main script. Must be
- either an absolute path or a relative path (i.e. relative to the
- current working directory) starting with `./` or `../`.
+* `filename` {string|URL} The path to the Worker’s main script or module. Must
+ be either an absolute path or a relative path (i.e. relative to the
+ current working directory) starting with `./` or `../`, or a WHATWG `URL`
+ object using `file:` protocol.
If `options.eval` is `true`, this is a string containing JavaScript code
rather than a path.
* `options` {Object}
@@ -536,8 +541,9 @@ changes:
to specify that the parent thread and the child thread should share their
environment variables; in that case, changes to one thread’s `process.env`
object will affect the other thread as well. **Default:** `process.env`.
- * `eval` {boolean} If `true`, interpret the first argument to the constructor
- as a script that is executed once the worker is online.
+ * `eval` {boolean} If `true` and the first argument is a `string`, interpret
+ the first argument to the constructor as a script that is executed once the
+ worker is online.
* `execArgv` {string[]} List of node CLI options passed to the worker.
V8 options (such as `--max-old-space-size`) and options that affect the
process (such as `--title`) are not supported. If set, this will be provided