{"id":22356339,"url":"https://github.com/do-/node-require-sliced","last_synced_at":"2026-03-07T03:02:52.568Z","repository":{"id":250601532,"uuid":"834889739","full_name":"do-/node-require-sliced","owner":"do-","description":"merge a single module source from multiple files","archived":false,"fork":false,"pushed_at":"2024-08-22T10:26:12.000Z","size":55,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-20T23:28:11.357Z","etag":null,"topics":["fresh","module","partitioned","require"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/do-.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}},"created_at":"2024-07-28T17:05:43.000Z","updated_at":"2024-11-05T15:37:09.000Z","dependencies_parsed_at":"2024-08-22T08:29:56.330Z","dependency_job_id":"bdbfd8b7-95f6-4bae-aef9-7e7ed03348dc","html_url":"https://github.com/do-/node-require-sliced","commit_stats":null,"previous_names":["do-/node-require-sliced"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/do-/node-require-sliced","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/do-%2Fnode-require-sliced","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/do-%2Fnode-require-sliced/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/do-%2Fnode-require-sliced/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/do-%2Fnode-require-sliced/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/do-","download_url":"https://codeload.github.com/do-/node-require-sliced/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/do-%2Fnode-require-sliced/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30206339,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-06T19:07:06.838Z","status":"online","status_checked_at":"2026-03-07T02:00:06.765Z","response_time":53,"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":["fresh","module","partitioned","require"],"created_at":"2024-12-04T14:09:56.344Z","updated_at":"2026-03-07T03:02:52.532Z","avatar_url":"https://github.com/do-.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![workflow](https://github.com/do-/node-require-sliced/actions/workflows/main.yml/badge.svg)\n![Jest coverage](./badges/coverage-jest%20coverage.svg)\n\n`require-sliced` is a node.js library implementing tools for working with [modules](https://nodejs.org/api/modules.html) whose source code may be partitioned across multiple eponymous files located in different directories.\n\nConsider a large application with the business logic implemented as a set of modules organized in topical directories, say `/crm`, `/hr` and so on. It may be convenient to have a common `users` module with some methods and properties defined in `/crm/users.js` and others in `/hr/users.js`. `require-sliced` lets developers do just that: it features the [ModuleMap](https://github.com/do-/node-require-sliced/wiki/ModuleMap) class designed to act as a registry of modules given as sets of partial source files to be assembled with [subclassable-object-merger](https://github.com/do-/node-subclassable-object-merger/wiki).\n\n[ModuleMap](https://github.com/do-/node-require-sliced/wiki/ModuleMap) tracks files' modification times and can clean up the [require.cache](https://nodejs.org/api/modules.html#requirecache) to always yield the last version, which is handy for development environments, but can be turned off with the `watch` option to avoid the related performance overhead.\n\n# Installation\n```sh\nnpm i require-sliced\n```\n\n# Usage\n```js\nconst {ModuleMap} = require ('require-sliced')\n\nconst codeRegistry = new ModuleMap ({\n  dir: {           // see https://www.npmjs.com/package/fs-iterators\n    root: ['/opt/myProject'], \n//    filter: (str, arr) =\u003e arr.at (-1) === 'API', // **/API/*\n//    live: false,\n  },\n// ext: '.js',\n// watch: false,   // uncomment to suppress checking for modifications\n// merger: new myObjectMerger (someOptions)\n})\n\ncodeRegistry.load () \n  // all at once: makes sense when watch === false\n\nconst usersModule = codeRegistry.get ('users') \n  // merge from all `require ('/opt/myProject/**/API/users.js')`\n\nusersModule.select () // for example\n\n// or just\n\ncodeRegistry.getMethod ('users', 'select') ()\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdo-%2Fnode-require-sliced","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdo-%2Fnode-require-sliced","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdo-%2Fnode-require-sliced/lists"}