worker_threads.setEnvironmentData(key[, value])


  • key <any> 任何任意的、可克隆的 JavaScript 值,可用作 <Map> 键。
  • value <any> 任何任意的、可克隆的 JavaScript 值,该值将被克隆并自动传递给所有新的 Worker 实例。如果 value 传入 undefined,则会删除之前为该 key 设置的任何值。

worker.setEnvironmentData() API 设置当前线程以及从当前上下文生成的所有新 Worker 实例中 worker.getEnvironmentData() 的内容。

🌐 The worker.setEnvironmentData() API sets the content of worker.getEnvironmentData() in the current thread and all new Worker instances spawned from the current context.