Skip to main content
getEnvironmentData - node__worker_threads.d.ts - Node documentation
function getEnvironmentData

Usage in Deno

```typescript import { getEnvironmentData } from "node:node__worker_threads.d.ts"; ```
getEnvironmentData(key: Serializable): Serializable
Within a worker thread, `worker.getEnvironmentData()` returns a clone of data passed to the spawning thread's `worker.setEnvironmentData()`. Every new `Worker` receives its own copy of the environment data automatically. ```js import { Worker, isMainThread, setEnvironmentData, getEnvironmentData, } from 'node:worker_threads'; if (isMainThread) { setEnvironmentData('Hello', 'World!'); const worker = new Worker(__filename); } else { console.log(getEnvironmentData('Hello')); // Prints 'World!'. } ```

Parameters

Any arbitrary, cloneable JavaScript value that can be used as a {Map} key.

Return Type