{"id":22308718,"url":"https://github.com/ratson/is-main","last_synced_at":"2025-09-04T02:41:47.340Z","repository":{"id":57277382,"uuid":"128795354","full_name":"ratson/is-main","owner":"ratson","description":"Check if current module is main module.","archived":false,"fork":false,"pushed_at":"2023-01-30T18:17:16.000Z","size":27,"stargazers_count":5,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-27T02:18:14.078Z","etag":null,"topics":["esm","esmodules","main","main-module","require-main"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ratson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-09T15:41:51.000Z","updated_at":"2025-02-12T11:50:00.000Z","dependencies_parsed_at":"2023-02-16T10:16:08.334Z","dependency_job_id":null,"html_url":"https://github.com/ratson/is-main","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/ratson/is-main","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ratson%2Fis-main","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ratson%2Fis-main/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ratson%2Fis-main/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ratson%2Fis-main/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ratson","download_url":"https://codeload.github.com/ratson/is-main/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ratson%2Fis-main/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267491855,"owners_count":24096277,"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","status":"online","status_checked_at":"2025-07-28T02:00:09.689Z","response_time":68,"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":["esm","esmodules","main","main-module","require-main"],"created_at":"2024-12-03T20:15:00.748Z","updated_at":"2025-07-29T06:30:58.325Z","avatar_url":"https://github.com/ratson.png","language":"TypeScript","readme":"# is-main\n\nCheck if current module is main module.\n\n## Installation\n\n```\nnpm install is-main --save\n```\n\n## Usage\n\n\u003c!-- eslint-disable strict --\u003e\n\n```js\nimport { isMain } from 'is-main'\n\nif (isMain(import.meta)) {\n  console.log('is main')\n}\n```\n\n```js\nconst { isMain } = require('is-main')\n\nif (isMain(module)) {\n  console.log('is main')\n}\n```\n\n## Note\n\nWhile it is useful to put main script with the module code in the same file,\nmove main script into a separate file is often better,\ngiven there is no standard way for detecting main script.\n\nSee this [Node issue](https://github.com/nodejs/node/issues/15760) for more information.\n\n## Related\n\n- [esmeta](https://github.com/ratson/esmeta) - Handy function to handle import.meta\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fratson%2Fis-main","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fratson%2Fis-main","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fratson%2Fis-main/lists"}