{"id":15062793,"url":"https://github.com/darky/repl-ns","last_synced_at":"2025-07-09T13:08:08.292Z","repository":{"id":64166263,"uuid":"573872281","full_name":"darky/repl-ns","owner":"darky","description":"Namespace for REPL driven development for TypeScript/JavaScript","archived":false,"fork":false,"pushed_at":"2023-08-24T18:24:03.000Z","size":29,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-06T10:14:09.745Z","etag":null,"topics":["clojure","development","driven","javascript","js","repl","ts","typescript"],"latest_commit_sha":null,"homepage":"","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/darky.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-03T17:44:04.000Z","updated_at":"2025-01-26T22:08:43.000Z","dependencies_parsed_at":"2024-09-24T23:46:44.862Z","dependency_job_id":null,"html_url":"https://github.com/darky/repl-ns","commit_stats":{"total_commits":20,"total_committers":1,"mean_commits":20.0,"dds":0.0,"last_synced_commit":"ad9d33aa29f29d77322796f31eac5d02fc263401"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/darky/repl-ns","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darky%2Frepl-ns","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darky%2Frepl-ns/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darky%2Frepl-ns/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darky%2Frepl-ns/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/darky","download_url":"https://codeload.github.com/darky/repl-ns/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darky%2Frepl-ns/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264465641,"owners_count":23612576,"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":["clojure","development","driven","javascript","js","repl","ts","typescript"],"created_at":"2024-09-24T23:46:42.013Z","updated_at":"2025-07-09T13:08:08.269Z","avatar_url":"https://github.com/darky.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# repl-ns\n\nNamespace for REPL driven development for TypeScript/JavaScript. \nInspired by Clojure namespaces.\nCurrently tested on Node.js, but potentially can be used on any JavaScript runtime (Deno, Bun, Browser and so on...)\n\n### Why REPL driven development?\n\n*TL;DR Because it fastest, glad and fun way to develop software. Clojure guys approve it*\n\nNode.js development process evolved gradually. At the beginning was nothing, and developers restarted node.js from scratch manually for code testing.\nThen some automation appears [nodemon](https://nodemon.io/). Fine! Now I can relax from boring `Ctrl+C` -\u003e `UP` -\u003e `Enter` process. But it's not enough! Restarting node.js process from scratch is very expensive! \n* Need to require in runtime all project files. Yes! All this hundreds files of your 3+ years old monolith 😊\n* Seems you have TypeScript too. Need to transpile all this kind with additional time wasting (Yeah! Say hello to ts-node perf tweak and all new TypeScript compilers, which written on Rust/C++/Go 😀)\n* And establish DB connection too\n* And establish Kafka/RabbitMQ/SQS connection too\n* And establish Redis connection too\n* And start HTTP server too\n\n☝️ And all this seconds wasting process for just testing one line of code, that I change?\u003cbr/\u003e\nMaybe better \"restart\" one function instead whole process, where this line of code was changed?\n\n### How to use (example)\n\nRun your node.js program with `--inpsect` flag. Exposed inspect protocol will be used for REPL driven development.\n\nThen organize code in your project using REPL driven development friendly style:\n\n*some-namespace.ts*\n\n```ts\nimport { ns } from 'repl-ns';\n\nexport const someNS = ns('some-namespace', {\n  fn() {\n    return 1 + 1\n  },\n});\n```\n\nAnd call namespace related functions anywhere:\n\n```ts\nimport { someNS } from 'src/some-namespace';\n\nsomeNS().fn() // 2\n```\n\nNow you can replace `someNS.fn` implementation in runtime without restarting node.js process. \u003cbr/\u003e\nJust edit *some-namespace.ts*\n\n```ts\n- return 1 + 1\n+ return 2 + 2\n```\n\nand use, for example, [node-remote-repl](https://github.com/darky/node-remote-repl) - `node-remote-repl some-namespace.ts`\u003cbr/\u003e\nNow anywhere `someNS().fn() // will return 4`\u003cbr/\u003e\nBTW, setup IDE for REPL driven development [VSCode example](https://github.com/darky/node-remote-repl#integration-with-ide)\n\nAwesome! 🦄 Now fastest REPL driven development with node.js at your fingertips \n\n### Detailed example\n\n```ts\nimport { ns } from 'repl-ns';\n\nexport const someNS = ns('some-namespace', {\n  fn() {\n    return 1 + 1 // functions always will be replaced in REPL\n  },\n  \n  obj: {foo: 'bar'} // objects will be preserved in REPL by default (for stateful)\n}, {\n  forceRewrite: true, // if you want force replace objects too, this option will be helpful\n  rewriteKeys: ['obj'], // or you can pick specific items for replacing\n  async before(props) {\n    // optional before hook namespace initialization\n    // old namespace payload will be passed in props (if exists)\n    // here you can close DB connection, stop HTTP server and so on\n  },\n  async after(props) {\n    // optional after hook namespace initialization\n    // new namespace payload will be passed in props\n    // here you can establish DB connection, start HTTP server and so on\n  },\n  sync: true // pass sync: true if your namespace has totally sync behaviour\n});\n\nawait someNS.ready // promise for ready state of namespace (before, after hooks executed yet)\n```\n\n### Real projects used repl-ns\n\nYou can explain code of projects:\n\n* [ytdl-tui](https://github.com/darky/ytdl-tui) - TUI for downloading YouTube videos, totally writen with REPL driven development approach using **repl-ns**\n\n### Caveats\n\nAvoid using relative paths in your project:\n\n```ts\nimport { someNS } from '../../some-namespace';\n```\n\nBecause REPL code is run in root and can't detect relative paths\n\nUse non-relative paths instead:\n\n```ts\nimport { someNS } from 'src/some-namespace';\n```\n\nProjects, which helps with non-relative paths:\n* [tsconfig-paths](https://github.com/dividab/tsconfig-paths)\n* [tsc-alias](https://github.com/justkey007/tsc-alias)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdarky%2Frepl-ns","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdarky%2Frepl-ns","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdarky%2Frepl-ns/lists"}