{"id":18563117,"url":"https://github.com/compulim/crawl-fs","last_synced_at":"2025-06-11T21:36:21.124Z","repository":{"id":82478835,"uuid":"51577614","full_name":"compulim/crawl-fs","owner":"compulim","description":"Recursively crawl the content of a folder","archived":false,"fork":false,"pushed_at":"2016-02-12T18:05:08.000Z","size":12,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-31T10:41:58.732Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/compulim.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-12T09:21:01.000Z","updated_at":"2016-02-12T18:05:29.000Z","dependencies_parsed_at":"2023-05-01T06:54:51.962Z","dependency_job_id":null,"html_url":"https://github.com/compulim/crawl-fs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/compulim%2Fcrawl-fs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/compulim%2Fcrawl-fs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/compulim%2Fcrawl-fs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/compulim%2Fcrawl-fs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/compulim","download_url":"https://codeload.github.com/compulim/crawl-fs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/compulim%2Fcrawl-fs/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259175555,"owners_count":22817017,"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-06T22:11:51.143Z","updated_at":"2025-06-11T21:36:21.088Z","avatar_url":"https://github.com/compulim.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# crawl-fs [![Build Status](https://travis-ci.org/compulim/crawl-fs.svg?branch=master)](https://travis-ci.org/compulim/crawl-fs)\n\nRecursively crawls a folder and returns a list of relative filenames. Iteration is flat and do not use recursive function.\n\n## Usage\n\nThere are few ways to use `crawl-fs`. Following examples assume the folder structure looks like this:\n```\n./folder-to-crawl/abc.txt\n./folder-to-crawl/def/\n./folder-to-crawl/def/ghi.txt\n./folder-to-crawl/xyz/\n```\n\nWe only returns files, empty folders are not included in result. Filenames are always relative to the base path, which relative to `process.cwd()`, specified in the function call.\n\n### Default returns an array\n\n```javascript\nrequire('crawl-fs')('folder-to-crawl/', (err, filenames) =\u003e {\n  assert.deepEqual(\n    filenames,\n    [\n      'abc.txt',\n      'def/ghi.txt'\n    ]\n  );\n});\n```\n\n### Returns a Promise with an iterator\n\nIf applicable, this approach is preferred as it is progressive and requires less memory.\n\n```javascript\nlet numCalled = 0;\n\nrequire('crawl-fs').withIterator('folder-to-crawl/', filename =\u003e {\n  // First iteration\n  numCalled === 0 \u0026\u0026 assert.equal(filename, 'abc.txt');\n\n  // Second iteration\n  numCalled === 1 \u0026\u0026 assert.equal(filename, 'def/ghi.txt');\n\n  numCalled++;\n}).then(() =\u003e {\n  // Completion\n  assert.equal(numCalled, 2);\n});\n```\n\n## Design considerations\nIf you think these design considerations are not valid, please [challenge](https://github.com/compulim/crawl-fs/issues/new/) us.\n* We did not use Promise progression, instead, we prefer iterator pattern with Promise resolver as finisher\n  * [Bluebird](http://bluebirdjs.com/docs/api/progression-migration.html) also discourage progression\n* We did not implement ES6 generator\n  * Our iterator is async, ES6 sync generator has no real benefits over array, in terms of time/space complexity\n\n## Changelog\n* 0.0.1 (2016-02-13) - Initial commit\n\n## Wishlist\n* [ ] When async generator is official in ES7, we should add new `.withAsyncGenerator()` function\n\n## Contribution\n\nWant to contribute? There are few easy ways:\n* Like us? Please [star](https://github.com/compulim/crawl-fs/stargazers) us!\n* Want to make it even awesome? [Send us your wish](https://github.com/compulim/crawl-fs/issues/new/).\n* Hate how it is working? [File an issue](https://github.com/compulim/crawl-fs/issues/) to us.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcompulim%2Fcrawl-fs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcompulim%2Fcrawl-fs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcompulim%2Fcrawl-fs/lists"}