{"id":19806632,"url":"https://github.com/timnew/lazily-require","last_synced_at":"2025-06-18T09:41:49.682Z","repository":{"id":143885260,"uuid":"21796997","full_name":"timnew/lazily-require","owner":"timnew","description":"Require node.js files from folder lazily. Could be useful in application.","archived":false,"fork":false,"pushed_at":"2014-09-13T09:19:07.000Z","size":160,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-28T18:00:46.367Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://github.com/timnew/lazily-require","language":"CoffeeScript","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/timnew.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}},"created_at":"2014-07-13T18:17:14.000Z","updated_at":"2014-09-13T09:19:08.000Z","dependencies_parsed_at":"2023-03-21T09:46:40.783Z","dependency_job_id":null,"html_url":"https://github.com/timnew/lazily-require","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/timnew/lazily-require","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timnew%2Flazily-require","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timnew%2Flazily-require/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timnew%2Flazily-require/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timnew%2Flazily-require/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/timnew","download_url":"https://codeload.github.com/timnew/lazily-require/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timnew%2Flazily-require/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260529092,"owners_count":23023099,"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":[],"created_at":"2024-11-12T09:08:03.317Z","updated_at":"2025-06-18T09:41:44.671Z","avatar_url":"https://github.com/timnew.png","language":"CoffeeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"lazily-require [![NPM version][npm-image]][npm-url] [![Build Status][ci-image]][ci-url] [![Dependency Status][depstat-image]][depstat-url]\n================\n\n\u003e Require node.js files from specific path. The file name is mapped to property name.\n\u003e The requirement happened lazily, the module won't be required until it is accessed.\n\u003e Could be useful in application, requirements can be simplified by using in conjunction with [approot](https://github.com/timnew/approot)\n\n## Install\n\nInstall using [npm][npm-url].\n\n    $ npm install lazily-require\n\n## Usage\n\n```javascript\n\nvar lazy = require('lazily-require');\n\nvar Models = lazy('./modules');\n\nvar User = Models.User;                   // equivalence to require('./modules/User')\n\nvar Credential = Models.admin.Credential; // equivalence to require('./modules/admin/Credential')\n\n```\n\nWhen used in conjunction of [approot](https://github.com/timnew/approot) to initialize the application environment.\n\n```javascript\nvar lazy = require('lazily-require');\n\nglobal.appRoot = require('approot')(__dirname).consolidate();\n\nglobal.configuration = require(appRoot.config('configuration'));\n\nglobal.Services = lazy appRoot.services();\nglobal.Routes = lazy appRoot.routes();\nglobal.Records = lazy appRoot.records();\nglobal.Models = lazy appRoot.models();\nglobal.Entities = lazy appRoot.entities();\n\n// Reference as\n\nvar user = Models.User;\nvar user = new User();\n\nvar user2 = new Models.User();\n\napp.get('/admin/login', Routers.admin.login.get);\n\n```\n   \n## License\nMIT\n\n[![NPM downloads][npm-downloads]][npm-url]\n\n[homepage]: https://github.com/timnew/lazily-require\n\n[npm-url]: https://npmjs.org/package/lazily-require\n[npm-image]: http://img.shields.io/npm/v/lazily-require.svg?style=flat\n[npm-downloads]: http://img.shields.io/npm/dm/lazily-require.svg?style=flat\n\n[ci-url]: https://drone.io/github.com/timnew/lazily-require/latest\n[ci-image]: https://drone.io/github.com/timnew/lazily-require/status.png\n\n[depstat-url]: https://gemnasium.com/timnew/lazily-require\n[depstat-image]: http://img.shields.io/gemnasium/timnew/lazily-require.svg?style=flat\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimnew%2Flazily-require","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimnew%2Flazily-require","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimnew%2Flazily-require/lists"}