{"id":15986360,"url":"https://github.com/stijnvanhulle/js-runtime","last_synced_at":"2025-03-17T23:30:47.818Z","repository":{"id":178686753,"uuid":"662218116","full_name":"stijnvanhulle/js-runtime","owner":"stijnvanhulle","description":"Detect which JavaScript runtime is being used","archived":false,"fork":false,"pushed_at":"2024-09-01T12:31:26.000Z","size":118,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-16T10:48:17.242Z","etag":null,"topics":["bun","deno","node","runtime"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/stijnvanhulle.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":["stijnvanhulle"]}},"created_at":"2023-07-04T16:00:17.000Z","updated_at":"2024-09-01T12:31:29.000Z","dependencies_parsed_at":"2023-07-22T09:45:14.325Z","dependency_job_id":"938eeb83-9b97-4cad-b878-a1a57115dce7","html_url":"https://github.com/stijnvanhulle/js-runtime","commit_stats":null,"previous_names":["stijnvanhulle/js-runtime"],"tags_count":7,"template":false,"template_full_name":"stijnvanhulle/template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stijnvanhulle%2Fjs-runtime","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stijnvanhulle%2Fjs-runtime/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stijnvanhulle%2Fjs-runtime/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stijnvanhulle%2Fjs-runtime/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stijnvanhulle","download_url":"https://codeload.github.com/stijnvanhulle/js-runtime/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243857993,"owners_count":20359259,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["bun","deno","node","runtime"],"created_at":"2024-10-08T03:00:40.234Z","updated_at":"2025-03-17T23:30:47.581Z","avatar_url":"https://github.com/stijnvanhulle.png","language":"TypeScript","funding_links":["https://github.com/sponsors/stijnvanhulle"],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003ch1\u003ejs-runtime\u003c/h1\u003e\n  \n  [![npm version][npm-version-src]][npm-version-href]\n  [![npm downloads][npm-downloads-src]][npm-downloads-href]\n  [![Coverage][coverage-src]][coverage-href]\n  [![License][license-src]][license-href]\n\u003c/div\u003e\n\nDetect which JavaScript runtime is being used, [Bun](https://bun.sh/), [Deno](https://deno.com/runtime) or [NodeJS](https://nodejs.org/).\n\n\n## Install\n\n```bash\nnpm i js-runtime\n```\n\n\n## Usage\n\n`index.js`\n\n```javascript\nimport { get } from \"js-runtime\";\n\nconsole.log(get()); //node or deno or bun\n```\n\n```bash\n$ bun index.js\n$ deno run index.js\n$ node index.js\n```\n\n## API\n\n### get\n\nReturn the current runtime.\n\nType: `function`\\\nReturns: `bun` | `deno` | `node`\n\n### isBun\n\nType: `function`\\\nReturns: `boolean`\n\n### isDeno\n\nType: `function`\\\nReturns: `boolean`\n\n\n### isNode\n\nType: `function`\\\nReturns: `boolean`\n\n### getVersion\n\nRetrieve the version used in the current runtime.\n\nType: `function`\\\nReturns: `string`\n\n\n### switcher\n\nSwitch based on the current runtime.\n\nType: `function`\\\nReturns: `T`\n\n`index.js`\n\n```typescript\nimport { switcher } from \"js-runtime\";\n\nconst message = switcher({\n  bun: \"Script is running with Bun\",\n  deno: \"Script is running with Deno\",\n  node: \"Script is running with Node\",\n})\n\nconsole.log(message)\n```\n\n```bash\n$ bun index.ts\nscript is running with Bun\n```\n\n### importer\n\nDynamic import based on switch data, see switcher.\n\nType: `function`\\\nReturns: `T`\n\n`index.js`\n\n```typescript\nimport { importer } from \"js-runtime\";\n\nconst SQLite = await importer({\n    bun: \"bun:sqlite\",\n    deno: \"https://deno.land/x/sqlite3@0.9.1/mod.ts\",\n    node: \"better-sqlite3\"\n});\n\nconsole.log(SQLite)\n```\n\n```bash\n$ bun index.ts\nbun:sqlite\n```\n\n## Supporting js-runtime\n\nJs Runtime uses an MIT-licensed open source project with its ongoing development made possible entirely by the support of Sponsors. If you would like to become a sponsor, please consider:\n\n- [Become a Sponsor on GitHub](https://github.com/sponsors/stijnvanhulle)\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/sponsors/stijnvanhulle\"\u003e\n    \u003cimg src=\"https://raw.githubusercontent.com/stijnvanhulle/sponsors/main/sponsors.svg\" alt=\"My sponsors\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\n\u003c!-- Badges --\u003e\n\n[npm-version-src]: https://img.shields.io/npm/v/js-runtime?flat\u0026colorA=18181B\u0026colorB=f58517\n[npm-version-href]: https://npmjs.com/package/js-runtime\n[npm-downloads-src]: https://img.shields.io/npm/dm/js-runtime?flat\u0026colorA=18181B\u0026colorB=f58517\n[npm-downloads-href]: https://npmjs.com/package/js-runtime\n[license-src]: https://img.shields.io/github/license/stijnvanhulle/js-runtime.svg?flat\u0026colorA=18181B\u0026colorB=f58517\n[license-href]: https://github.com/stijnvanhulle/js-runtime/blob/main/LICENSE\n[build-src]: https://img.shields.io/github/actions/workflow/status/stijnvanhulle/js-runtime/ci.yaml?style=flat\u0026colorA=18181B\u0026colorB=f58517\n[build-href]: https://www.npmjs.com/package/js-runtime\n[minified-src]: https://img.shields.io/bundlephobia/min/js-runtime?style=flat\u0026colorA=18181B\u0026colorB=f58517\n[minified-href]: https://www.npmjs.com/package/js-runtime\n[coverage-src]: https://img.shields.io/codecov/c/github/stijnvanhulle/js-runtime?style=flat\u0026colorA=18181B\u0026colorB=f58517\n[coverage-href]: https://www.npmjs.com/package/js-runtime\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstijnvanhulle%2Fjs-runtime","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstijnvanhulle%2Fjs-runtime","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstijnvanhulle%2Fjs-runtime/lists"}