{"id":17531179,"url":"https://github.com/bartozzz/scan-dir","last_synced_at":"2026-02-03T07:34:40.588Z","repository":{"id":38173465,"uuid":"65031707","full_name":"Bartozzz/scan-dir","owner":"Bartozzz","description":"Searches for files in a directory and executes a callback for each. All insecure symlinks, dotfiles and files without extension are ignored.","archived":false,"fork":false,"pushed_at":"2023-01-07T03:55:50.000Z","size":1818,"stargazers_count":2,"open_issues_count":12,"forks_count":0,"subscribers_count":3,"default_branch":"development","last_synced_at":"2025-02-24T17:07:04.243Z","etag":null,"topics":["autoloader","directory","files","fs","import","require"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/call-dir","language":"JavaScript","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/Bartozzz.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2016-08-05T16:04:53.000Z","updated_at":"2025-02-11T15:48:45.000Z","dependencies_parsed_at":"2023-02-06T11:16:35.199Z","dependency_job_id":null,"html_url":"https://github.com/Bartozzz/scan-dir","commit_stats":null,"previous_names":["bartozzz/call-dir"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bartozzz%2Fscan-dir","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bartozzz%2Fscan-dir/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bartozzz%2Fscan-dir/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bartozzz%2Fscan-dir/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Bartozzz","download_url":"https://codeload.github.com/Bartozzz/scan-dir/tar.gz/refs/heads/development","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242191571,"owners_count":20087005,"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":["autoloader","directory","files","fs","import","require"],"created_at":"2024-10-20T17:23:08.462Z","updated_at":"2026-02-03T07:34:40.509Z","avatar_url":"https://github.com/Bartozzz.png","language":"JavaScript","readme":"\u003cdiv align=\"center\"\u003e\n  \u003ch1\u003escan-dir\u003c/h1\u003e\n\n![Tests](https://github.com/Bartozzz/scan-dir/workflows/Tests/badge.svg)\n[![Known Vulnerabilities](https://snyk.io/test/github/Bartozzz/scan-dir/badge.svg?targetFile=package.json)](https://snyk.io/test/github/Bartozzz/scan-dir?targetFile=package.json)\n[![npm package size](https://img.badgesize.io/Bartozzz/scan-dir/master/dist/index.js?compression=gzip)](https://www.npmjs.com/package/scan-dir)\n[![npm version](https://img.shields.io/npm/v/@bartozzz/scan-dir.svg)](https://www.npmjs.com/package/@bartozzz/scan-dir)\n[![npm dependency Status](https://david-dm.org/Bartozzz/@bartozzz/scan-dir.svg)](https://www.npmjs.com/package/@bartozzz/scan-dir)\n[![npm downloads](https://img.shields.io/npm/dt/@bartozzz/scan-dir.svg)](https://www.npmjs.com/package/@bartozzz/scan-dir)\n\n\u003cbr\u003e\n\n**scan-dir** searches for files in a directory and executes a callback for each. All symlinks, dotfiles and files without extension are ignored. Supports deep-loading. It can be used as an autoloader for JavaScript.\n\n\u003c/div\u003e\n\n## Installation\n\n```bash\n$ npm install @bartozzz/scan-dir\n```\n\n## Usage\n\n```javascript\nimport scan, { scanRecursively } from \"scan-dir\";\n\nscan(directory, callback);\nscanRecursively(directory, callback);\n```\n\n### Examples\n\n#### Basic loading\n\n```javascript\nimport path from \"path\";\nimport scan, from \"scan-dir\";\n\nconst models = path.resolve(__dirname, \"./path/to/models\");\nconst routes = path.resolve(__dirname, \"./path/to/routes\");\n\nscan(models, (fpath, fname) =\u003e {\n  console.log(`Found file: ${fname} (absolute path: ${fpath})`);\n});\n\n// You can initialize modules from a directory easily:\nscan(models, (fpath) =\u003e require(fpath)(some, variables, ...here));\nscan(routes, (fpath) =\u003e require(fpath)(some, variables, ...here));\n```\n\n#### Deep loading\n\n```javascript\nimport path from \"path\";\nimport scan, { scanRecursively } from \"scan-dir\";\n\nconst modules = path.resolve(__dirname, \"../node_modules\");\n\n// Those two calls are equivalents:\nscan(modules, (fpath, fname) =\u003e /* … */, true);\nscanRecursively(modules, (fpath, fname) =\u003e /* … */);\n```\n\n## Tests\n\n```bash\n$ npm test\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbartozzz%2Fscan-dir","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbartozzz%2Fscan-dir","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbartozzz%2Fscan-dir/lists"}