{"_id":"environment","_rev":"3283420","name":"environment","description":"Check which JavaScript environment your code is running in at runtime: browser, Node.js, Bun, etc","dist-tags":{"latest":"1.1.0"},"maintainers":[{"name":"sindresorhus","email":""}],"time":{"modified":"2024-05-23T02:11:43.000Z","created":"2012-06-27T23:09:48.666Z","1.1.0":"2024-05-14T07:02:20.386Z","1.0.0":"2024-04-28T18:30:43.930Z","0.0.2":"2012-06-28T15:34:51.604Z","0.0.1":"2012-06-27T23:09:48.666Z"},"users":{},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"repository":{"type":"git","url":"git+https://github.com/sindresorhus/environment.git"},"versions":{"1.1.0":{"name":"environment","version":"1.1.0","description":"Check which JavaScript environment your code is running in at runtime: browser, Node.js, Bun, etc","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/environment.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"types":"./index.d.ts","default":"./index.js"},"sideEffects":false,"engines":{"node":">=18"},"scripts":{"test":"xo && ava && tsc index.d.ts"},"keywords":["runtime","environment","env","execution","engine","platform","context","js","javascript","is","check","checking","detect","detection","browser","node","bun","deno","electron","jsdom","webworker","worker","serviceworker","macos","ios","iphone","ipad","windows","linux","android","os","operating","system"],"devDependencies":{"ava":"^6.1.3","typescript":"^5.4.5","xo":"^0.58.0"},"xo":{"rules":{"n/prefer-global/process":"off"}},"_id":"environment@1.1.0","gitHead":"102e1c7e34f9d77791d323bed8c5ff79c71b1348","types":"./index.d.ts","bugs":{"url":"https://github.com/sindresorhus/environment/issues"},"homepage":"https://github.com/sindresorhus/environment#readme","_nodeVersion":"20.12.2","_npmVersion":"10.6.0","dist":{"shasum":"8e86c66b180f363c7ab311787e0259665f45a9f1","size":2766,"noattachment":false,"key":"/environment/-/environment-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/environment/download/environment-1.1.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/environment_1.1.0_1715670140211_0.5873498122088465"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-05-14T07:02:20.386Z","publish_time":1715670140386,"_source_registry_name":"default","_cnpm_publish_time":1715670140386},"1.0.0":{"name":"environment","version":"1.0.0","description":"Check which JavaScript environment your code is running in at runtime: browser, Node.js, Bun, etc","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/environment.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"types":"./index.d.ts","default":"./index.js"},"sideEffects":false,"engines":{"node":">=18"},"scripts":{"test":"xo && ava && tsc index.d.ts"},"keywords":["runtime","environment","env","execution","engine","platform","context","js","javascript","is","check","checking","detect","detection","browser","node","bun","deno","electron","jsdom","webworker","worker","serviceworker"],"devDependencies":{"ava":"^6.1.2","typescript":"^5.4.5","xo":"^0.58.0"},"_id":"environment@1.0.0","gitHead":"03ba151c2e400c61acda627b096286ed23c445e0","types":"./index.d.ts","bugs":{"url":"https://github.com/sindresorhus/environment/issues"},"homepage":"https://github.com/sindresorhus/environment#readme","_nodeVersion":"18.20.2","_npmVersion":"10.6.0","dist":{"shasum":"73a40178302a5c12c05bb402de058a1a339b4efc","size":2280,"noattachment":false,"key":"/environment/-/environment-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/environment/download/environment-1.0.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/environment_1.0.0_1714329043783_0.021114051965937852"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-04-28T18:30:43.930Z","publish_time":1714329043930,"_source_registry_name":"default","_cnpm_publish_time":1714329043930},"0.0.2":{"author":{"name":"Brandon Benvie","email":"brandon@bbenvie.com","url":"http://bbenvie.com"},"name":"environment","description":"Provides node's `process.env` object functionality as stand-alone functions instead of a C++ fake object that does weird things. As an added bonus, if running node with Proxies enabled (\"node --harmony\") it also exports a function that creates an `Environment` object that is similar to `process.env` but behaves like a real object.","version":"0.0.2","keywords":["env","environment","process.env"],"homepage":"https://github.com/Benvie/node-environment","repository":{"type":"git","url":"git://github.com/Benvie/node-environment.git"},"main":"environment.js","scripts":{"install":"node-gyp rebuild"},"gypfile":true,"_id":"environment@0.0.2","dist":{"shasum":"2d82630392999501eaabb5a233c9ccc2cf99da58","size":35964,"noattachment":false,"key":"/environment/-/environment-0.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/environment/download/environment-0.0.2.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_cnpmcore_publish_time":"2021-12-23T09:49:55.166Z","hasInstallScript":true,"publish_time":1340897691604,"_cnpm_publish_time":1340897691604},"0.0.1":{"author":{"name":"Brandon Benvie","email":"brandon@bbenvie.com","url":"http://bbenvie.com"},"name":"environment","description":"Provides node's `process.env` object functionality as stand-alone functions instead of a C++ fake object that does weird things. As an added bonus, if running node with Proxies enabled (\"node --harmony\") it also exports a function that creates an `Environment` object that is similar to `process.env` but behaves like a real object.","version":"0.0.1","keywords":["env","environment","process.env"],"homepage":"https://github.com/Benvie/node-environment","repository":{"type":"git","url":"git://github.com/Benvie/node-environment.git"},"main":"environment.js","scripts":{"install":"node-gyp rebuild"},"gypfile":true,"_id":"environment@0.0.1","dist":{"shasum":"1be6c909e06f63b21ff7248af0bc012ffe64b4a0","size":35990,"noattachment":false,"key":"/environment/-/environment-0.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/environment/download/environment-0.0.1.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_cnpmcore_publish_time":"2021-12-23T09:49:54.108Z","hasInstallScript":true,"publish_time":1340838588666,"_cnpm_publish_time":1340838588666}},"readme":"# environment\n\n> Check which JavaScript environment your code is running in at runtime\n\n## Install\n\n```sh\nnpm install environment\n```\n\n## Usage\n\n```js\nimport {isBrowser, isNode} from 'environment';\n\nif (isBrowser) {\n\tconsole.log('Running in a browser!');\n}\n\nif (isNode) {\n\tconsole.log('Running in Node.js!');\n}\n```\n\n> [!NOTE]\n> Runtime checks should be used sparingly. Prefer [conditional package exports](https://nodejs.org/api/packages.html#conditional-exports) and [imports](https://nodejs.org/api/packages.html#subpath-imports) whenever possible.\n\n## API\n\n### `isBrowser`\n\nCheck if the code is running in a web browser environment.\n\n### `isNode`\n\nCheck if the code is running in a [Node.js](https://nodejs.org) environment.\n\n### `isBun`\n\nCheck if the code is running in a [Bun](https://bun.sh) environment.\n\n### `isDeno`\n\nCheck if the code is running in a [Deno](https://deno.com) environment.\n\n### `isElectron`\n\nCheck if the code is running in an [Electron](https://www.electronjs.org) environment.\n\n### `isJsDom`\n\nCheck if the code is running in a [jsdom](https://github.com/jsdom/jsdom) environment.\n\n### `isWebWorker`\n\nCheck if the code is running in a [Web Worker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API#worker_global_contexts_and_functions) environment, which could be either a dedicated worker, shared worker, or service worker.\n\n### `isDedicatedWorker`\n\nCheck if the code is running in a [Dedicated Worker](https://developer.mozilla.org/en-US/docs/Web/API/DedicatedWorkerGlobalScope) environment.\n\n### `isSharedWorker`\n\nCheck if the code is running in a [Shared Worker](https://developer.mozilla.org/en-US/docs/Web/API/SharedWorkerGlobalScope) environment.\n\n### `isServiceWorker`\n\nCheck if the code is running in a [Service Worker](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerGlobalScope) environment.\n\n### `isMacOs`\n\nCheck if the code is running on macOS.\n\n### `isWindows`\n\nCheck if the code is running on Windows.\n\n### `isLinux`\n\nCheck if the code is running on Linux.\n\n### `isIos`\n\nCheck if the code is running on iOS.\n\n### `isAndroid`\n\nCheck if the code is running on Android.\n\n## Related\n\n- [is-in-ci](https://github.com/sindresorhus/is-in-ci) - Check if the process is running in a CI environment\n- [is64bit](https://github.com/sindresorhus/is64bit) - Check if the operating system CPU architecture is 64-bit or 32-bit\n- [is](https://github.com/sindresorhus/is) - Type check values\n","_attachments":{},"homepage":"https://github.com/sindresorhus/environment#readme","bugs":{"url":"https://github.com/sindresorhus/environment/issues"},"license":"MIT"}