@@ -120,6 +120,9 @@ added: v10.5.0
120
120
An arbitrary JavaScript value that contains a clone of the data passed
121
121
to this thread’s ` Worker ` constructor.
122
122
123
+ The data is cloned as if using [ ` postMessage() ` ] [ `port.postMessage()` ] ,
124
+ using the [ HTML structured clone algorithm] [ ] .
125
+
123
126
``` js
124
127
const { Worker , isMainThread , workerData } = require (' worker_threads' );
125
128
@@ -222,10 +225,16 @@ added: v10.5.0
222
225
223
226
Sends a JavaScript value to the receiving side of this channel.
224
227
` value ` will be transferred in a way which is compatible with
225
- the [ HTML structured clone algorithm] [ ] . In particular, it may contain circular
226
- references and objects like typed arrays that the ` JSON ` API is not able
227
- to stringify.
228
+ the [ HTML structured clone algorithm] [ ] .
228
229
230
+ In particular, the significant differences to ` JSON ` are:
231
+ - ` value ` may contain circular references.
232
+ - ` value ` may contain instances of builtin JS types such as ` RegExp ` s,
233
+ ` BigInt ` s, ` Map ` s, ` Set ` s, etc.
234
+ - ` value ` may contained typed arrays, both using ` ArrayBuffer ` s
235
+ and ` SharedArrayBuffer ` s. and
236
+ - ` value ` may contain [ ` WebAssembly.Module ` ] [ ] instances.
237
+ - ` value ` may not contain native (C++-backed) objects other than ` MessagePort ` s.
229
238
230
239
``` js
231
240
const { MessageChannel } = require (' worker_threads' );
@@ -567,6 +576,7 @@ active handle in the event system. If the worker is already `unref()`ed calling
567
576
[ `MessagePort` ] : #worker_threads_class_messageport
568
577
[ `SharedArrayBuffer` ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer
569
578
[ `Uint8Array` ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array
579
+ [ `WebAssembly.Module` ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module
570
580
[ `Worker` ] : #worker_threads_class_worker
571
581
[ `'close'` event ] : #worker_threads_event_close
572
582
[ `cluster` module ] : cluster.html
0 commit comments