{"id":20772722,"url":"https://github.com/leadcodedev/recursive-fs","last_synced_at":"2026-04-19T16:01:42.594Z","repository":{"id":47818911,"uuid":"358379349","full_name":"LeadcodeDev/recursive-fs","owner":"LeadcodeDev","description":"It is often difficult to retrieve and use files stored locally at your application, recursive-fs allows you to retrieve any file saved in a folder or sub-folder at a defined location.","archived":false,"fork":false,"pushed_at":"2021-08-13T20:02:52.000Z","size":115,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-31T16:48:18.585Z","etag":null,"topics":["file","fs","javascript","recursive","systeme","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/LeadcodeDev.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":"2021-04-15T20:06:01.000Z","updated_at":"2021-10-22T18:28:41.000Z","dependencies_parsed_at":"2022-09-07T22:54:13.095Z","dependency_job_id":null,"html_url":"https://github.com/LeadcodeDev/recursive-fs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/LeadcodeDev/recursive-fs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LeadcodeDev%2Frecursive-fs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LeadcodeDev%2Frecursive-fs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LeadcodeDev%2Frecursive-fs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LeadcodeDev%2Frecursive-fs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LeadcodeDev","download_url":"https://codeload.github.com/LeadcodeDev/recursive-fs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LeadcodeDev%2Frecursive-fs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32012787,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T20:23:30.271Z","status":"online","status_checked_at":"2026-04-19T02:00:07.110Z","response_time":55,"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":["file","fs","javascript","recursive","systeme","typescript"],"created_at":"2024-11-17T12:22:43.985Z","updated_at":"2026-04-19T16:01:42.573Z","avatar_url":"https://github.com/LeadcodeDev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Recursive-fs\n\nEasily access your files in any folder or sub-folder.\n\n## Objective\n\nIt is often difficult to retrieve and use files stored locally at your application, `fs-recursive` allows you to retrieve any file saved in a folder or sub-folder at a defined location.\n\n## How to use\n\nInstall the module in your project via YARN\n\n```bash\nyarn add fs-recursive\n```\n\nOr NPM\n\n```bash\nnpm install fs-recursive\n```\n\nThe `fs-recursive` is very simple to use, you need to use the followed function :\n\n```ts\nfetch(\n  directory: string,\n  extentions: Array\u003cstring\u003e,\n  encode?: Buffer | string | undefined,\n  callback?: (file: File) =\u003e void\n): Promise\u003cMap\u003cstring, File\u003e\u003e\n\nfetchExpression (\n  path: string,\n  filenamePattern: RegExp,\n  encode: Encode,\n  excludes?: Array\u003cstring\u003e,\n  callback?: (file: File) =\u003e void\n): Promise\u003cMap\u003cstring, File\u003e\u003e\n\nfetchSortedExpression (\n  path: string,\n  filenamePattern: RegExp,\n  sortedExtensions: Array\u003cstring\u003e,\n  encode: Encode,\n  excludes?: Array\u003cstring\u003e,\n  callback?: (file: File) =\u003e void\n): Promise\u003cArray\u003cFile\u003e\u003e\n```\n\n### An example is always more telling\n\n```ts\nimport { fetch } from 'fs-recursive';\n\nconst directory = path.join(process.cwd(), 'folder');\nconst extensions = ['ts', 'json'];\n\nconst files = await fetch(directory, extensions, 'utf-8'); // return Map\u003cstring, File\u003e\nconsole.log(files.entries().next().value[1]);\n\n/**\n * Log the followed result\n *\n * File {\n *   path: 'E:\\\\WindowsData\\\\Desktop\\\\folder`\\\\File.ts',\n *   filename: 'File',\n *   extension: 'ts',\n *   size: 1513   👈 expredded in bytes\n * }\n */\n```\n\nYou can get the same result using `RegExp`\n\n```ts\nimport { fetchExpression } from 'fs-recursive';\n\nconst directory = path.join(process.cwd(), 'folder');\nconst expression = /.*\\.ts$/;\n\nconst files = await fetchExpression(directory, expression, 'utf-8'); // return Map\u003cstring, File\u003e\nconsole.log(files.entries().next().value[1]);\n\n/**\n * Log the followed result\n *\n * File {\n *   path: 'E:\\\\WindowsData\\\\Desktop\\\\folder`\\\\File.ts',\n *   filename: 'File',\n *   extension: 'ts',\n *   size: 1513   👈 expredded in bytes\n * }\n */\n```\n\nThen you can access to other data like this\n\n```ts\nconst files = await fetch(directory, extensions, 'utf-8'); // return Map\u003cstring, File\u003e\nconst file = files.entries().next().value[1];\nconst stats = await file.getStats();\n\nconsole.log(stats);\n/**\n * Stats {\n *   dev: 310369320,\n *   mode: 33206,\n *   nlink: 1,\n *   uid: 0,\n *   gid: 0,\n *   rdev: 0,\n *   blksize: 4096,\n *   ino: 562949956735823,\n *   size: 72,\n *   blocks: 0,\n *   atimeMs: 1618523067313.032,\n *   mtimeMs: 1618521064609.6714,\n *   ctimeMs: 1618521064609.6714,\n *   birthtimeMs: 1618521033264.188,\n *   atime: 2021-04-15T21:44:27.313Z,\n *   mtime: 2021-04-15T21:11:04.610Z,\n *   ctime: 2021-04-15T21:11:04.610Z,\n *   birthtime: 2021-04-15T21:10:33.264Z\n * }\n */\n```\n\nYou can sort results by their extension\n\n```ts\nimport { fetchSortedExpression } from 'fs-recursive';\n\nconst extensions = ['ts', 'js'];\nconst expression = /.*\\.(ts|js)$/;\nconst files = await fetchSortedExpression(\n\tprocess.cwd(),\n\texpression,\n\textensions,\n\t'utf-8'\n);\n\nconsole.log(files);\n\n/**\n * Log the followed result\n *\n * [\n * \tFile {\n *   path: 'E:\\\\WindowsData\\\\Desktop\\\\folder`\\\\File.ts',\n *   filename: 'File',\n *   extension: 'ts',\n *   size: 1513   👈 expredded in bytes\n *\t},\n * \tFile {\n *   path: 'E:\\\\WindowsData\\\\Desktop\\\\folder`\\\\File.js',\n *   filename: 'File',\n *   extension: 'js',\n *   size: 1513   👈 expredded in bytes\n * \t}\n * ]\n */\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleadcodedev%2Frecursive-fs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleadcodedev%2Frecursive-fs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleadcodedev%2Frecursive-fs/lists"}