{"id":49061460,"url":"https://github.com/dandre3000/environment","last_synced_at":"2026-04-27T07:02:05.151Z","repository":{"id":351904412,"uuid":"1212849025","full_name":"dandre3000/environment","owner":"dandre3000","description":null,"archived":false,"fork":false,"pushed_at":"2026-04-17T00:35:30.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-20T02:44:21.780Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dandre3000.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-16T19:45:58.000Z","updated_at":"2026-04-17T00:35:14.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/dandre3000/environment","commit_stats":null,"previous_names":["dandre3000/environment"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/dandre3000/environment","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dandre3000%2Fenvironment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dandre3000%2Fenvironment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dandre3000%2Fenvironment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dandre3000%2Fenvironment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dandre3000","download_url":"https://codeload.github.com/dandre3000/environment/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dandre3000%2Fenvironment/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32326122,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T23:26:28.701Z","status":"online","status_checked_at":"2026-04-27T02:00:06.769Z","response_time":128,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-04-20T02:15:41.941Z","updated_at":"2026-04-27T07:02:05.139Z","avatar_url":"https://github.com/dandre3000.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @dandre3000/environment\n\nCheck if code is running on the main thread or a worker of a browser, node, bun or deno instance.\n\n## Installation\n\nnpm i @dandre3000/environment\n\n## Usage\n\n```js\nimport { isMainThread, runtime } from '@dandre3000/environment'\n\nif (isMainThread) {\n    const url = new URL(import.meta.url)\n    \n    if (runtime === 'node') {\n        const worker = new (await import('node:worker_threads')).Worker(url)\n\n        worker.on('message', data =\u003e console.log(data))\n    } else {\n        const worker = new Worker(url, { type: 'module' })\n\n        worker.addEventListener('message', ({ data }) =\u003e console.log(data))\n    }\n} else {\n    if (runtime === 'node') {\n        (await import('node:worker_threads')).parentPort.postMessage('YOOO')\n    } else {\n        postMessage('YOOO')\n    }\n}\n```\n\n## Exports\n\n#### runtime: 'bun' | 'browser' | 'deno' | 'node'\n\nThe name of the current runtme.\n\n#### isMainThread: boolean\n\nTrue if the current global scope is the main thread or false otherwise.\n\n## License\n\n[MIT](https://github.com/dandre3000/environment/blob/main/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdandre3000%2Fenvironment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdandre3000%2Fenvironment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdandre3000%2Fenvironment/lists"}