@@ -99,7 +99,6 @@ added: v20.6.0
9999    [`  initialize` ][] hook.
100100  * `  transferList`  {Object\[ ]} [transferrable objects][] to be passed into the
101101    `  initialize`  hook.
102- * Returns: {any} returns whatever was returned by the `  initialize`  hook.
103102
104103Register a module that exports [hooks][] that customize Node.js module 
105104resolution and loading behavior. See [Customization hooks][]. 
@@ -348,7 +347,7 @@ names and signatures, and they must be exported as named exports.
348347
349348` ` `  mjs
350349export  async  function  initialize ({ number, port }) {
351-   //  Receive  data from `register`, return data to  `register`.
350+   //  Receives  data from `register`.
352351}
353352
354353export  async  function  resolve (specifier , context , nextResolve ) {
@@ -386,20 +385,15 @@ added: v20.6.0
386385> Stability: 1.1 - Active development 
387386
388387* `  data`  {any} The data from ` register (loader, import .meta.url, { data  })` .
389- * Returns: {any} The data to be returned to the caller of `  register` .
390388
391389The `  initialize`  hook provides a way to define a custom function that runs in
392390the hooks thread when the hooks module is initialized. Initialization happens 
393391when the hooks module is registered via [`  register` ][].
394392
395- This hook can send and receive data from a [`  register` ][] invocation, including
396- ports and other transferrable objects. The return value of `  initialize`  must be
397- either: 
398- 
399- * `  undefined` ,
400- * something that can be posted as a message between threads (e.g. the input to 
401-   [`  port.postMessage` ][]),
402- * a `  Promise`  resolving to one of the aforementioned values.
393+ This hook can receive data from a [`  register` ][] invocation, including
394+ ports and other transferrable objects. The return value of `  initialize`  can be a
395+ {Promise}, in which case it will be awaited before the main application thread 
396+ execution resumes. 
403397
404398Module customization code: 
405399
@@ -408,7 +402,6 @@ Module customization code:
408402
409403export  async  function  initialize ({ number, port }) {
410404  port .postMessage (` increment: ${ number +  1 } `  );
411-   return  ' ok'  ;
412405}
413406` ` ` 
414407
@@ -428,13 +421,11 @@ port1.on('message', (msg) => {
428421  assert .strictEqual (msg, ' increment: 2'  );
429422});
430423
431- const   result   =   register (' ./path-to-my-hooks.js'  , {
424+ register (' ./path-to-my-hooks.js'  , {
432425  parentURL:  import .meta.url,
433426  data:  { number:  1 , port:  port2 },
434427  transferList:  [port2],
435428});
436- 
437- assert .strictEqual (result, ' ok'  );
438429` ` ` 
439430
440431` ` `  cjs
@@ -452,13 +443,11 @@ port1.on('message', (msg) => {
452443  assert .strictEqual (msg, ' increment: 2'  );
453444});
454445
455- const   result   =   register (' ./path-to-my-hooks.js'  , {
446+ register (' ./path-to-my-hooks.js'  , {
456447  parentURL:  pathToFileURL (__filename ),
457448  data:  { number:  1 , port:  port2 },
458449  transferList:  [port2],
459450});
460- 
461- assert .strictEqual (result, ' ok'  );
462451` ` ` 
463452
464453#### `  resolve (specifier, context, nextResolve)` 
@@ -1116,7 +1105,6 @@ returned object contains the following keys:
11161105[`  Uint8Array ` ]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array
11171106[`  initialize` ]: #initialize
11181107[`  module ` ]: modules.md#the-module-object
1119- [`  port .postMessage ` ]: worker_threads.md#portpostmessagevalue-transferlist
11201108[`  port .ref ()` ]: worker_threads.md#portref
11211109[`  port .unref ()` ]: worker_threads.md#portunref
11221110[`  register` ]: #moduleregisterspecifier-parenturl-options
0 commit comments