{"id":15776972,"url":"https://github.com/jaywcjlove/recursive-readdir-files","last_synced_at":"2025-05-13T01:21:37.525Z","repository":{"id":37933192,"uuid":"397689376","full_name":"jaywcjlove/recursive-readdir-files","owner":"jaywcjlove","description":"Node.js module to list all files in a directory or any subdirectories.","archived":false,"fork":false,"pushed_at":"2025-03-22T12:24:31.000Z","size":201,"stargazers_count":5,"open_issues_count":4,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-09T09:22:31.869Z","etag":null,"topics":["files","javascript","nodejs","readdir","recursive","recursive-readdir"],"latest_commit_sha":null,"homepage":"https://jaywcjlove.github.io/recursive-readdir-files","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/jaywcjlove.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"ko_fi":"jaywcjlove","buy_me_a_coffee":"jaywcjlove","custom":["https://www.paypal.me/kennyiseeyou","https://jaywcjlove.github.io/#/sponsor"]}},"created_at":"2021-08-18T17:50:40.000Z","updated_at":"2025-03-05T07:49:11.000Z","dependencies_parsed_at":"2022-09-09T13:21:45.647Z","dependency_job_id":"27b9f66f-a07c-4eb2-98e6-266267582d5a","html_url":"https://github.com/jaywcjlove/recursive-readdir-files","commit_stats":{"total_commits":92,"total_committers":3,"mean_commits":"30.666666666666668","dds":"0.14130434782608692","last_synced_commit":"65739491d2750b3ee242425268f9e13834092a6e"},"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaywcjlove%2Frecursive-readdir-files","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaywcjlove%2Frecursive-readdir-files/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaywcjlove%2Frecursive-readdir-files/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaywcjlove%2Frecursive-readdir-files/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jaywcjlove","download_url":"https://codeload.github.com/jaywcjlove/recursive-readdir-files/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253851593,"owners_count":21973770,"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":["files","javascript","nodejs","readdir","recursive","recursive-readdir"],"created_at":"2024-10-04T17:41:50.526Z","updated_at":"2025-05-13T01:21:37.483Z","avatar_url":"https://github.com/jaywcjlove.png","language":"TypeScript","funding_links":["https://ko-fi.com/jaywcjlove","https://buymeacoffee.com/jaywcjlove","https://www.paypal.me/kennyiseeyou","https://jaywcjlove.github.io/#/sponsor"],"categories":[],"sub_categories":[],"readme":"recursive-readdir-files\n===\n\u003c!--rehype:style=display: flex; padding: 150px 0 0 0; align-items: center; justify-content: center; font-size: 38px; border: 0; border-radius: 5px;--\u003e\n\n[![Buy me a coffee](https://img.shields.io/badge/Buy%20me%20a%20coffee-048754?logo=buymeacoffee)](https://jaywcjlove.github.io/#/sponsor) \n[![Coverage Status](https://jaywcjlove.github.io/recursive-readdir-files/badges.svg)](https://jaywcjlove.github.io/recursive-readdir-files/lcov-report/)\n[![npm version](https://img.shields.io/npm/v/recursive-readdir-files.svg)](https://www.npmjs.com/package/recursive-readdir-files)\n[![NPM Download](https://img.shields.io/npm/dm/recursive-readdir-files.svg?style=flat)](https://www.npmjs.com/package/recursive-readdir-files)\n\u003c!--rehype:style=text-align: center;--\u003e\n\nNode.js module to list all files in a directory or any subdirectories.\n\n## Installation\n\nThis package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c): Node 12+ is needed to use it and it must be `import` instead of `require`.\n\n```bash\nnpm install recursive-readdir-files\n```\n\nIf you still want to use in CommonJS, you can use dynamic `import()` to load.\n\n```typescript\nconst recursiveReaddirFiles = await import('recursive-readdir-files');\n\n// Fix compiling in typescript.\n// https://github.com/microsoft/TypeScript/issues/43329#issuecomment-922544562\nconst { getExt, recursiveReaddirFiles } = await (Function('return import(\"recursive-readdir-files\")')()) as Promise\u003ctypeof import(\"recursive-readdir-files\")\u003e;\n```\n\n## Usage\n\n```js\nimport recursiveReaddirFiles from 'recursive-readdir-files';\n\nconst files = await recursiveReaddirFiles(process.cwd(), {\n  ignored: /\\/(node_modules|\\.git)/\n});\n\n// `files` is an array\nconsole.log(files);\n// ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓\n// [\n//   {\n//     dev: 16777233,\n//     mode: 33188,\n//     nlink: 1,\n//     uid: 501,\n//     gid: 20,\n//     rdev: 0,\n//     blksize: 4096,\n//     ino: 145023089,\n//     size: 89,\n//     blocks: 8,\n//     atimeMs: 1649303678077.934,\n//     mtimeMs: 1649303676847.1777,\n//     ctimeMs: 1649303676847.1777,\n//     birthtimeMs: 1649301118132.6782,\n//     atime: 2022-04-07T03:54:38.078Z,\n//     mtime: 2022-04-07T03:54:36.847Z,\n//     ctime: 2022-04-07T03:54:36.847Z,\n//     birthtime: 2022-04-07T03:11:58.133Z,\n//     name: 'watch.ts',\n//     path: '/Users/xxx/watch.ts',\n//     ext: 'ts'\n//   },\n//   // ...\n// ]\n```\n\nOr\n\n```js\nrecursiveReaddirFiles(process.cwd(), {\n  ignored: /\\/(node_modules|\\.git)/\n}, (filepath, state) =\u003e {\n  console.log(filepath);\n  // 👉 /Users/xxx/watch.ts\n  console.log(state.isFile());      // 👉 true\n  console.log(state.isDirectory()); // 👉 false\n  console.log(state);\n  // ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓\n  // {\n  //   dev: 16777233,\n  //   mode: 33188,\n  //   nlink: 1,\n  //   uid: 501,\n  //   gid: 20,\n  //   rdev: 0,\n  //   blksize: 4096,\n  //   ino: 145023089,\n  //   size: 89,\n  //   blocks: 8,\n  //   atimeMs: 1649303678077.934,\n  //   mtimeMs: 1649303676847.1777,\n  //   ctimeMs: 1649303676847.1777,\n  //   birthtimeMs: 1649301118132.6782,\n  //   atime: 2022-04-07T03:54:38.078Z,\n  //   mtime: 2022-04-07T03:54:36.847Z,\n  //   ctime: 2022-04-07T03:54:36.847Z,\n  //   birthtime: 2022-04-07T03:11:58.133Z,\n  //   name: 'watch.ts',\n  //   path: '/Users/xxx/watch.ts',\n  //   ext: 'ts'\n  // }\n})\n```\n\n## Options\n\n```ts\nexport interface RecursiveReaddirFilesOptions {\n  /**\n   * Ignore files\n   * @example `/\\/(node_modules|\\.git)/`\n   */\n  ignored?: RegExp;\n  /**\n   * Specifies a list of `glob` patterns that match files to be included in compilation.\n   * @example `/(\\.json)$/`\n   */\n  include?: RegExp;\n  /**\n   * Specifies a list of files to be excluded from compilation.\n   * @example `/(package\\.json)$/`\n   */\n  exclude?: RegExp;\n  /** Provide filtering methods to filter data. */\n  filter?: (item: IFileDirStat) =\u003e boolean;\n}\n```\n\n## Result\n\n```ts\nimport fs from 'node:fs';\nexport interface IFileDirStat extends Partial\u003cfs.Stats\u003e {\n  /**\n   * @example `/a/sum.jpg` =\u003e `sum.jpg`\n   */\n  name: string;\n  /**\n   * @example `/basic/src/utils/sum.ts`\n   */\n  path: string;\n  /**\n   * @example `/a/b.jpg` =\u003e `jpg`\n   */\n  ext?: string;\n}\ndeclare type Callback = (filepath: string, stat: IFileDirStat) =\u003e void;\nexport default function recursiveReaddirFiles(rootPath: string, options?: RecursiveReaddirFilesOptions, callback?: Callback): Promise\u003cIFileDirStat[]\u003e;\nexport { recursiveReaddirFiles };\nexport declare const getStat: (filepath: string) =\u003e Promise\u003cIFileDirStat\u003e;\n/**\n * Get ext\n * @param {String} filePath `/a/b.jpg` =\u003e `jpg`\n */\nexport declare const getExt: (filePath: string) =\u003e string;\n```\n\n## Contributors\n\nAs always, thanks to our amazing contributors!\n\n\u003ca href=\"https://github.com/jaywcjlove/recursive-readdir-files/graphs/contributors\"\u003e\n  \u003cimg src=\"https://jaywcjlove.github.io/recursive-readdir-files/CONTRIBUTORS.svg\" /\u003e\n\u003c/a\u003e\n\nMade with [action-contributors](https://github.com/jaywcjlove/github-action-contributors).\n\n## License\n\nLicensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaywcjlove%2Frecursive-readdir-files","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjaywcjlove%2Frecursive-readdir-files","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaywcjlove%2Frecursive-readdir-files/lists"}