{"id":18340862,"url":"https://github.com/amercier/files-by-directory","last_synced_at":"2026-05-15T21:32:17.507Z","repository":{"id":57235831,"uuid":"157860995","full_name":"amercier/files-by-directory","owner":"amercier","description":"NodeJS library to list files by directory, recursively, using asynchronous iteration (for-await-of).","archived":false,"fork":false,"pushed_at":"2020-05-31T00:09:13.000Z","size":405,"stargazers_count":2,"open_issues_count":11,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-20T13:46:58.210Z","etag":null,"topics":["async","async-await","directory","filesystem","for-await-of","nodejs","walker"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/amercier.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-16T11:54:36.000Z","updated_at":"2023-03-08T16:54:06.000Z","dependencies_parsed_at":"2022-08-23T16:30:27.372Z","dependency_job_id":null,"html_url":"https://github.com/amercier/files-by-directory","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/amercier/files-by-directory","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amercier%2Ffiles-by-directory","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amercier%2Ffiles-by-directory/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amercier%2Ffiles-by-directory/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amercier%2Ffiles-by-directory/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amercier","download_url":"https://codeload.github.com/amercier/files-by-directory/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amercier%2Ffiles-by-directory/sbom","scorecard":{"id":189102,"data":{"date":"2025-08-11","repo":{"name":"github.com/amercier/files-by-directory","commit":"e7e6c1f69ee6950b5047a449fccf889317288404"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/9 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE.md:0","Info: FSF or OSI recognized license: ISC License: LICENSE.md:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 25 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-16T20:17:55.516Z","repository_id":57235831,"created_at":"2025-08-16T20:17:55.516Z","updated_at":"2025-08-16T20:17:55.516Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33080777,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-15T20:25:35.270Z","status":"ssl_error","status_checked_at":"2026-05-15T20:25:34.732Z","response_time":103,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["async","async-await","directory","filesystem","for-await-of","nodejs","walker"],"created_at":"2024-11-05T20:24:29.099Z","updated_at":"2026-05-15T21:32:17.492Z","avatar_url":"https://github.com/amercier.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# files-by-directory\n\n\u003e List files by directory, recursively, using [asynchronous iteration].\n\u003e\n\u003e This can be particularly useful for directory structures with lots of files, or slow files\n\u003e systems, since you can start treating the results straight away, without having to wait for the\n\u003e entire structure to be scanned.\n\n[![Latest Stable Version](https://img.shields.io/npm/v/files-by-directory.svg)](https://www.npmjs.com/package/files-by-directory)\n[![Build Status](https://img.shields.io/travis/amercier/files-by-directory/master.svg)](https://travis-ci.org/amercier/files-by-directory)\n[![NPM Downloads](https://img.shields.io/npm/dm/files-by-directory.svg)](https://www.npmjs.com/package/files-by-directory)\n\n[![dependencies Status](https://david-dm.org/amercier/files-by-directory/status.svg)](https://david-dm.org/amercier/files-by-directory)\n[![Test Coverage](https://img.shields.io/codecov/c/github/amercier/files-by-directory/master.svg)](https://codecov.io/github/amercier/files-by-directory?branch=master)\n[![API Documentation](https://doc.esdoc.org/github.com/amercier/files-by-directory/badge.svg)](https://doc.esdoc.org/github.com/amercier/files-by-directory/)\n\n## Installation\n\nPrerequisites: [Node.js](https://nodejs.org/) 6+, **npm** 3+.\n\n```bash\nnpm install --save files-by-directory\n```\n\n## API\n\n### `filesByDirectory(paths: string[], options = {}): AsyncIterator\u003cstring[]\u003e`\n\nScan directories recursively, and generate 1 array per directory, containing the file paths.\n\n```bash\n# Directory structure:\nlevel1\n├── level2a\n│   ├── level3\n│   │   ├── file3a\n│   │   └── file3b\n│   └── file2a\n├── level2b\n│   └── file2b\n├── file1a\n└── file1b\n```\n\n```js\nconst filesByDirectory = require('files-by-directory');\n\nfor await (const files of filesByDirectory(['level1'])) {\n  console.log(files);\n  console.log('---');\n}\n```\n\n```\n[\n  'level1/file1a',\n  'level1/file1b'\n]\n---\n[\n  'level1/level2a/file2a'\n]\n---\n[\n  'level1/level2a/level3/file3a',\n  'level1/level2a/level3/file3b'\n]\n---\n[\n  'level1/level2b/file2b'\n]\n---\n```\n\n**Notes:**\n\n- If a path is encountered twice, it is only generated once.\n- By default symbolic links are treated as regular files, even though they link to directories.\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003ccode\u003eoptions.followSymlinks\u003c/code\u003e (default: \u003ccode\u003efalse\u003c/code\u003e)\u003c/summary\u003e\n\nWhen set to `true`, resolves any symbolic link to the directory it's pointing to, while preserving the link's path.\n\n```bash\n# Directory structure:\nlevel1\n├── level2\n│   ├── file2a\n│   └── file2b\n├── file1a\n├── link-to-directory -\u003e level2\n└── link-to-file -\u003e file1a\n```\n\n```js\nfor await (const files of filesByDirectory(['level1']/*, { followSymlinks: false }*/} )) {\n  console.log(files);\n}\n// [ 'level1/file1a', 'level1/link-to-directory', 'link-to-file' ]\n// [ 'level1/level2/file2a', 'level1/level2/file2b' ]\n\nfor await (const files of filesByDirectory(['level1'], { followSymlinks: true })) {\n  console.log(files);\n}\n// [ 'level1/file1a', 'level1/link-to-file' ]\n// [ 'level1/level2/file2a', 'level1/level2/file2b' ]\n// [ 'level1/link-to-directory/file2a', 'level1/link-to-directory/file2b' ]\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003ccode\u003eoptions.excludeSymlinks\u003c/code\u003e (default: \u003ccode\u003efalse\u003c/code\u003e)\u003c/summary\u003e\n\nWhen set to `true`, excludes symbolic links from results:\n\n```bash\n# Directory structure:\nlevel1\n├── level2a\n│   ├── file2a\n│   └── file2b\n├── level2b -\u003e level2a\n├── file1a\n└── file1b -\u003e file1a\n```\n\n```js\nfor await (const files of filesByDirectory(['level1']/*, { excludeSymlinks: false }*/} )) {\n  console.log(files);\n}\n// [ 'level1/level2b', 'level1/file1a', 'level1/file1b' ]\n// [ 'level1/level2a/file2a', 'level1/level2a/file2b' ]\n\nfor await (const files of filesByDirectory(['level1'], { excludeSymlinks: true })) {\n  console.log(files);\n}\n// [ 'level1/file1a', 'level1/file1b' ]\n// [ 'level1/level2a/file2a', 'level1/level2a/file2b' ]\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003ccode\u003eoptions.directoriesFirst\u003c/code\u003e (default: \u003ccode\u003efalse\u003c/code\u003e)\u003c/summary\u003e\n\nWhen set to `true`, proceed directories (recursively) before files.\n\n```bash\n# Directory structure:\nlevel1\n├── level2a\n│   ├── level3\n│   │   ├── file3a\n│   │   └── file3b\n│   └── file2a\n├── level2b\n│   └── file2b\n├── file1a\n└── file1b\n```\n\n```js\nfor await (const files of filesByDirectory(['level1']/*, { directoriesFirst: false }*/} )) {\n  console.log(files);\n}\n// [ 'level1/file1a', 'level1/file1b' ]\n// [ 'level1/level2a/file2a' ]\n// [ 'level1/level2a/level3/file3a', 'level1/level2a/level3/file3b' ]\n// [ 'level1/level2b/file2b' ]\n\nfor await (const files of filesByDirectory(['level1'], { directoriesFirst: true })) {\n  console.log(files);\n}\n// [ 'level1/level2a/level3/file3a', 'level1/level2a/level3/file3b' ]\n// [ 'level1/level2a/file2a' ]\n// [ 'level1/level2b/file2b' ]\n// [ 'level1/file1a', 'level1/file1b' ]\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003ccode\u003eoptions.showDirectories\u003c/code\u003e (default: \u003ccode\u003efalse\u003c/code\u003e)\u003c/summary\u003e\n\nWhen set to `true`, includes an entry containing the directory.\n\n```bash\n# Directory structure:\nlevel1\n├── level2\n│   ├── file2a\n│   └── file2b\n├── file1a\n└── file1b\n```\n\n```js\nfor await (const files of filesByDirectory(['level1']/*, { showDirectories: false }*/} )) {\n  console.log(files);\n}\n// [ 'level1/file1a', 'level1/file1b' ]\n// [ 'level1/level2/file2a', 'level1/level2/file2b' ]\n\nfor await (const files of filesByDirectory(['level1'], { showDirectories: true })) {\n  console.log(files);\n}\n// [ 'level1', 'level1/file1a', 'level1/file1b' ]\n// [ 'level1/level2', 'level1/level2/file2a', 'level1/level2/file2b' ]\n\nfor await (const [directory, ...files] of filesByDirectory(['level1'], { showDirectories: true })) {\n  console.log(directory, files);\n}\n// level1 [ 'level1/file1a', 'level1/file1b' ]\n// level1/level2 [ 'level1/level2/file2a', 'level1/level2/file2b' ]\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003ccode\u003eoptions.skipEmptyDirectories\u003c/code\u003e (default: \u003ccode\u003etrue\u003c/code\u003e)\u003c/summary\u003e\n\nWhen set to `false`, includes empty files lists.\n\n```bash\n# Directory structure:\nlevel1\n├── level2a (only directories)\n│   └── level3\n│       └── file3a\n├── level2b\n│   └── (empty)\n└── file1a\n```\n\n```js\nfor await (const files of filesByDirectory(['level1']/*, { skipEmptyDirectories: true }*/} )) {\n  console.log(files);\n}\n// [ 'level1/file1a' ]\n// [ 'level1/level2a/level3/file3a' ]\n\nfor await (const files of filesByDirectory(['level1'], { skipEmptyDirectories: false } )) {\n  console.log(files);\n}\n// [ 'level1/file1a' ]\n// []\n// [ 'level1/level2a/level3/file3a' ]\n// []\n```\n\n**Note:** this can be useful when combined with `showDirectories` option:\n\n```js\nconst options = { skipEmptyDirectories: false, showDirectories: true };\nfor await (const [directory, ...files] of filesByDirectory(['level1'], options)) {\n  console.log(directory, files);\n}\n// level1 [ 'level1/file1a' ]\n// level1/level2a []\n// level1/level2a/level3 [ 'level1/level2a/level3/file3a' ]\n// level1/empty-directory []\n```\n\n\u003c/details\u003e\n\n## Asynchronous iteration\n\n[Asynchronous iteration] using `for-await-of` syntax requires Node 10+. For older version of NodeJS, either use:\n\n- [Babel] with [@babel/transform-async-generator-functions], or\n- Use `async/await` syntax without `for-await-of` (NodeJS 8+, see [demo-node-8.js](demo-node-8.js))\n- Use Promises with a custom `invoke` function (NodeJS 6+, see [demo-node-6.js](demo-node-6.js))\n\n## Contributing\n\nPlease refer to the [guidelines for contributing](./CONTRIBUTING.md).\n\n[![devDependencies Status](https://david-dm.org/amercier/files-by-directory/dev-status.svg)](https://david-dm.org/amercier/files-by-directory?type=dev)\n\n## License\n\n[![License](https://img.shields.io/npm/l/files-by-directory.svg)](LICENSE.md)\n\n---\n\n[asynchronous iteration]: http://2ality.com/2016/10/asynchronous-iteration.html\n[babel]: https://babeljs.io/\n[@babel/transform-async-generator-functions]: https://babeljs.io/docs/en/babel-plugin-proposal-async-generator-functions\n\n\u003csup\u003e_Created with [npm-p\u0026#97;ckage-skeleton](https://github.com/amercier/files-by-directory)._\u003c/sup\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famercier%2Ffiles-by-directory","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famercier%2Ffiles-by-directory","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famercier%2Ffiles-by-directory/lists"}