{"id":13847352,"url":"https://github.com/privatenumber/dbgr","last_synced_at":"2025-03-21T00:30:22.139Z","repository":{"id":66125487,"uuid":"359030618","full_name":"privatenumber/dbgr","owner":"privatenumber","description":"Lightweight debugger for Node.js","archived":false,"fork":false,"pushed_at":"2021-04-21T01:24:09.000Z","size":45,"stargazers_count":44,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"develop","last_synced_at":"2025-03-17T18:53:51.505Z","etag":null,"topics":["alternative","debugger","lightweight","nodejs"],"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/privatenumber.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}},"created_at":"2021-04-18T02:58:50.000Z","updated_at":"2021-09-04T21:36:46.000Z","dependencies_parsed_at":"2023-03-10T23:38:12.594Z","dependency_job_id":null,"html_url":"https://github.com/privatenumber/dbgr","commit_stats":{"total_commits":5,"total_committers":1,"mean_commits":5.0,"dds":0.0,"last_synced_commit":"ac23deca9475b65678221626466554d1d77c8115"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/privatenumber%2Fdbgr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/privatenumber%2Fdbgr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/privatenumber%2Fdbgr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/privatenumber%2Fdbgr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/privatenumber","download_url":"https://codeload.github.com/privatenumber/dbgr/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244717078,"owners_count":20498279,"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":["alternative","debugger","lightweight","nodejs"],"created_at":"2024-08-04T18:01:17.597Z","updated_at":"2025-03-21T00:30:21.804Z","avatar_url":"https://github.com/privatenumber.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# dbgr \u003ca href=\"https://npm.im/dbgr\"\u003e\u003cimg src=\"https://badgen.net/npm/v/dbgr\"\u003e\u003c/a\u003e \u003ca href=\"https://npm.im/dbgr\"\u003e\u003cimg src=\"https://badgen.net/npm/dm/dbgr\"\u003e\u003c/a\u003e \u003ca href=\"https://packagephobia.now.sh/result?p=dbgr\"\u003e\u003cimg src=\"https://packagephobia.now.sh/badge?p=dbgr\"\u003e\u003c/a\u003e\n\n**dbgr** is a lightweight debugger function that pauses your script, watches the current file for any changes and only re-runs the specific code that's passed in to it. It's just like `debugger` but requires no IDE or browser dev-tools integrations.\n\n\n\u003csub\u003eIf you like this project, please star it \u0026 [follow me](https://github.com/privatenumber) to see what other cool projects I'm working on! ❤️\u003c/sub\u003e\n\n## 🙋‍♂️ Why?\nYou can set breakpoints in Node.js with breakpoints or `debugger` statements, but it could be a hassle to set up and can slow down your script.\n\nWhen you're debugging something heavy with slow startup (eg. server, headless Chrome, etc), you want to use something simple \u0026 light to debug.\n\n## 🚀 Install\n```sh\nnpm i -D dbgr\n```\n\n## 🚦 Quick Setup\n\n```js\nimport dbgr from 'dbgr'\n\n// Some async process\n(async () =\u003e {\n\n    // ...\n\n    await dbgr((resume) =\u003e {\n        console.log('The debugger has started');\n\n        // Write code here and hit save to\n        // automatically re-run this function\n\n        // Call resume() and save to resume the debugger\n\n        // ↓ The eval below is necessary for this to work\n    }, _ =\u003e eval(_))\n})();\n```\n\n## 🙋‍♀️ FAQ\n### How does it work?\nUpon invoking dbgr, it detects the file path of the caller by using [V8 stack trace API](https://v8.dev/docs/stack-trace-api) via [callsites](https://github.com/sindresorhus/callsites). It then watches the file for changes using [`fs.watch`](https://nodejs.org/docs/latest/api/fs.html#fs_fs_watch_filename_options_listener). When a change is detected, it parses the source code using [acorn](https://github.com/acornjs/acorn) to extract the specific function passed into dbgr. It then passes it into the `_ =\u003e eval(_)` to run in the original context.\n\n### Does it work in TypeScript files?\nYes. While the AST parser acorn is designed for ES parsing, TS files can be loosely parsed via [acorn-loose](https://github.com/acornjs/acorn/tree/master/acorn-loose), and the content inside the dbgr hook has the types stripped via [esbuild](https://esbuild.github.io/) for it to be \"safely\" `eval()`'d by the JavaScript runtime.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprivatenumber%2Fdbgr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprivatenumber%2Fdbgr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprivatenumber%2Fdbgr/lists"}