{"id":18777276,"url":"https://github.com/iyowei/scan-dir-each-sync","last_synced_at":"2025-12-16T19:30:16.064Z","repository":{"id":57119764,"uuid":"438925965","full_name":"iyowei/scan-dir-each-sync","owner":"iyowei","description":"串行扫描文件夹，扫描的同时支持更新、过滤操作，一定程度复用遍历。","archived":false,"fork":false,"pushed_at":"2021-12-18T07:49:27.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-29T18:47:41.837Z","etag":null,"topics":["dir","fs","iyowei","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iyowei.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-12-16T09:07:38.000Z","updated_at":"2021-12-31T07:54:40.000Z","dependencies_parsed_at":"2022-08-23T19:00:57.617Z","dependency_job_id":null,"html_url":"https://github.com/iyowei/scan-dir-each-sync","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iyowei%2Fscan-dir-each-sync","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iyowei%2Fscan-dir-each-sync/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iyowei%2Fscan-dir-each-sync/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iyowei%2Fscan-dir-each-sync/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iyowei","download_url":"https://codeload.github.com/iyowei/scan-dir-each-sync/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239687436,"owners_count":19680732,"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":["dir","fs","iyowei","nodejs","walker"],"created_at":"2024-11-07T20:09:33.893Z","updated_at":"2025-12-16T19:30:16.028Z","avatar_url":"https://github.com/iyowei.png","language":"JavaScript","readme":"[node version badge]: https://img.shields.io/badge/node.js-%3E%3D12.20.0-brightgreen?style=flat\u0026logo=Node.js\n[download node.js]: https://nodejs.org/en/download/\n[prs welcome badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat\n[lsDirSync]: https://github.com/iyowei/ls-dir-sync\n[lsdir]: https://github.com/iyowei/ls-dir\n[scandireach]: https://github.com/iyowei/scan-dir-each\n[scandirsync]: https://github.com/iyowei/scan-dir-sync\n[scandir]: https://github.com/iyowei/scan-dir\n\n# scanDirEachSync(path, worker = () =\u003e {}, raw = false)\n\n\u003e 串行扫描文件夹，扫描的同时支持更新、过滤操作，一定程度复用遍历。\n\n## 使用\n\n- `path` 待扫描的路径，**必需提供**，{String}\n- `worker` 处理器，如果扫描的同时需要更新、过滤操作可提供，一定程度复用穷举，**必需提供**，{ Function }\n  - 返回 {Object | Boolean}\n    - `false` 过滤掉当前扫描结果\n    - `true` 保留当前扫描结果\n    - 对象字面量，保留 / 更新当前扫描结果\n    - 其它类型则默认为没有任何处理\n- `raw` 是否专门返回未加工的扫描结果，默认 `false`，**可选**，{ Boolean }\n- 返回，扫描结果 { Array }\n  - 如果设置了 `raw` 为 `true`，则返回 **二维数组**，第一项为加工后的扫描结果，第二项为未加工的扫描结果\n  - 默认返回 **一维数组**，即：加工后的扫描结果\n\n```js\nimport { log } from \"console\";\nimport scanDirEachSync from \"@iyowei/scan-dir-each-sync\";\n\nlog(\n  scanDirEachSync(\n    process.cwd(),\n    (cur, index) =\u003e {\n      return index % 2 === 0 ? cur : false;\n    },\n    true\n  )\n);\n\n/**\n * [\n *   [\n *     {\n *       path: '',\n *       dirent: [Dirent]\n *     },\n *     ...\n *   ],\n *   [\n *     {\n *       path: '',\n *       dirent: [Dirent]\n *     },\n *     ...\n *   ]\n * ]\n */\n```\n\n## 安装\n\n[![Node Version Badge][node version badge]][download node.js]\n\n```shell\n# Pnpm\npnpm add @iyowei/scan-dir-each-sync\n\n# yarn\nyarn add @iyowei/scan-dir-each-sync\n\n# npm\nnpm add @iyowei/scan-dir-each-sync\n```\n\n## 相关\n- [**`lsDirSync()`**][lsDirSync]，串行扫描文件夹；\n- [**`lsDir()`**][lsdir]，并行扫描文件夹；\n- [**`scanDirSync()`**][scandirsync]，`worker` 选填，有 `worker`，行为同 `scanDirEachSync()` 一致，否则与 `lsDirSync()` 一致，如果项目中同时使用了 `scanDirEachSync()`、`lsDirSync()`，则推荐使用 `scanDirSync()`；\n- [**`scanDir()`**][scandir]，`worker` 选填，有 `worker`，行为同 `scanDirEach()` 一致，否则与 `lsDir()` 一致，如果项目中同时使用了 `scanDirEach()`、`lsDir()`，则推荐使用 `scanDir()`；\n- [**`scanDirEach()`**][scandireach]，可在扫描的同时更新或过滤数据，**并行** 实现；\n\n## 参与贡献\n\n![PRs Welcome][prs welcome badge]\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiyowei%2Fscan-dir-each-sync","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiyowei%2Fscan-dir-each-sync","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiyowei%2Fscan-dir-each-sync/lists"}