{"_id":"rd","_rev":"2865279","name":"rd","description":"Read all directory recursively 列出（遍历）目录下的所有文件，包括子目录","dist-tags":{"latest":"2.0.1"},"maintainers":[{"name":"leizongmin","email":""}],"time":{"modified":"2022-09-15T09:39:45.000Z","created":"2013-06-27T04:40:44.038Z","2.0.1":"2018-06-27T03:35:11.137Z","2.0.0":"2018-06-08T07:10:51.856Z","1.1.2":"2017-08-16T06:00:24.402Z","1.1.1":"2017-08-16T05:57:04.397Z","1.1.0":"2017-08-14T10:19:39.389Z","1.0.0":"2016-10-27T07:44:31.348Z","0.0.2":"2014-03-09T08:06:01.353Z","0.0.1":"2013-06-27T04:40:44.038Z"},"users":{},"author":{"name":"Zongmin Lei","email":"leizongmin@gmail.com"},"repository":{"type":"git","url":"git+https://github.com/leizongmin/node-rd.git"},"versions":{"2.0.1":{"name":"rd","version":"2.0.1","description":"Read all directory recursively 列出（遍历）目录下的所有文件，包括子目录","main":"index.js","typings":"index.d.ts","files":["index.js","index.d.ts","promises.js","promises.d.ts"],"scripts":{"format":"prettier --write \"**/*.ts\" \"**/*.js\"","test":"npm run format && mocha -t 5000","test-cov":"istanbul cover _mocha --report lcovonly -- -t 5000 -R spec && cat ./coverage/lcov.info | coveralls","prepublish":"npm run format"},"repository":{"type":"git","url":"git+https://github.com/leizongmin/node-rd.git"},"keywords":["directory","recursively"],"author":{"name":"Zongmin Lei","email":"leizongmin@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/leizongmin/node-rd/issues"},"homepage":"https://github.com/leizongmin/node-rd#readme","devDependencies":{"coveralls":"^3.0.1","istanbul":"^0.4.5","mocha":"^5.2.0","prettier":"^1.13.6"},"dependencies":{"@types/node":"^10.3.6"},"gitHead":"b9288d5607908bfb94222e12588739863f025c00","_id":"rd@2.0.1","_npmVersion":"6.1.0","_nodeVersion":"8.11.3","_npmUser":{"name":"leizongmin","email":"leizongmin@gmail.com"},"dist":{"shasum":"e18a8af5b2f7440c0db1523ca04c6e0f9660003f","size":5793,"noattachment":false,"key":"/rd/-/rd-2.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/rd/download/rd-2.0.1.tgz"},"maintainers":[{"name":"leizongmin","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rd_2.0.1_1530070510849_0.7425078568465167"},"_cnpmcore_publish_time":"2021-12-19T11:51:20.540Z","publish_time":1530070511137,"_cnpm_publish_time":1530070511137},"2.0.0":{"name":"rd","version":"2.0.0","description":"Read all directory recursively 列出（遍历）目录下的所有文件，包括子目录","main":"index.js","typings":"index.d.ts","files":["index.js","index.d.ts","promises.js","promises.d.ts"],"scripts":{"format":"prettier --write \"**/*.ts\" \"**/*.js\"","test":"npm run format && mocha -t 5000","test-cov":"istanbul cover _mocha --report lcovonly -- -t 5000 -R spec && cat ./coverage/lcov.info | coveralls","prepublish":"npm run format"},"repository":{"type":"git","url":"git+https://github.com/leizongmin/node-rd.git"},"keywords":["directory","recursively"],"author":{"name":"Zongmin Lei","email":"leizongmin@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/leizongmin/node-rd/issues"},"homepage":"https://github.com/leizongmin/node-rd#readme","devDependencies":{"coveralls":"^2.11.14","istanbul":"^0.4.5","mocha":"^3.1.2","prettier":"^1.13.4"},"dependencies":{"@types/node":"^8.0.20"},"gitHead":"426e53b41cfe9a6d3f97a1456656409919a55fb9","_id":"rd@2.0.0","_npmVersion":"5.6.0","_nodeVersion":"8.11.1","_npmUser":{"name":"leizongmin","email":"leizongmin@gmail.com"},"dist":{"shasum":"4bb4e98ce5524ca95acef482fe0e5450ec603954","size":5817,"noattachment":false,"key":"/rd/-/rd-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/rd/download/rd-2.0.0.tgz"},"maintainers":[{"name":"leizongmin","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rd_2.0.0_1528441851805_0.7574350123654976"},"_cnpmcore_publish_time":"2021-12-19T11:51:19.676Z","publish_time":1528441851856,"_cnpm_publish_time":1528441851856},"1.1.2":{"name":"rd","version":"1.1.2","description":"Read all directory recursively 列出（遍历）目录下的所有文件，包括子目录","main":"index.js","typings":"index.d.ts","files":["index.js","index.d.ts"],"scripts":{"test":"npm run lint && mocha -t 5000","test-cov":"istanbul cover _mocha --report lcovonly -- -t 5000 -R spec && cat ./coverage/lcov.info | coveralls","lint":"eslint . --fix","prepublish":"npm run lint"},"repository":{"type":"git","url":"git+https://github.com/leizongmin/node-rd.git"},"keywords":["directory","recursively"],"author":{"name":"Zongmin Lei","email":"leizongmin@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/leizongmin/node-rd/issues"},"homepage":"https://github.com/leizongmin/node-rd#readme","devDependencies":{"mocha":"^3.1.2","coveralls":"^2.11.14","eslint":"^3.8.1","eslint-config-lei":"0.0.14","eslint-plugin-promise":"^3.3.0","istanbul":"^0.4.5"},"dependencies":{"@types/node":"^8.0.20"},"gitHead":"701878853547bc8cdbc608766ec3cd398ee4dd72","_id":"rd@1.1.2","_shasum":"86297e2025608ee5576c1b451e6997e679ef6b1d","_from":".","_npmVersion":"3.10.10","_nodeVersion":"6.11.2","_npmUser":{"name":"leizongmin","email":"leizongmin@gmail.com"},"dist":{"shasum":"86297e2025608ee5576c1b451e6997e679ef6b1d","size":5340,"noattachment":false,"key":"/rd/-/rd-1.1.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/rd/download/rd-1.1.2.tgz"},"maintainers":[{"name":"leizongmin","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rd-1.1.2.tgz_1502863224328_0.5077451365068555"},"directories":{},"_cnpmcore_publish_time":"2021-12-19T11:51:18.786Z","publish_time":1502863224402,"_cnpm_publish_time":1502863224402},"1.1.1":{"name":"rd","version":"1.1.1","description":"Read all directory recursively 列出（遍历）目录下的所有文件，包括子目录","main":"index.js","typings":"index.d.ts","files":["index.js","index.d.ts"],"scripts":{"test":"npm run lint && mocha -t 5000","test-cov":"istanbul cover _mocha --report lcovonly -- -t 5000 -R spec && cat ./coverage/lcov.info | coveralls","lint":"eslint . --fix","prepublish":"npm run lint"},"repository":{"type":"git","url":"git+https://github.com/leizongmin/node-rd.git"},"keywords":["directory","recursively"],"author":{"name":"Zongmin Lei","email":"leizongmin@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/leizongmin/node-rd/issues"},"homepage":"https://github.com/leizongmin/node-rd#readme","devDependencies":{"mocha":"^3.1.2","coveralls":"^2.11.14","eslint":"^3.8.1","eslint-config-lei":"0.0.14","eslint-plugin-promise":"^3.3.0","istanbul":"^0.4.5"},"dependencies":{"@types/node":"^8.0.20"},"gitHead":"0f67ca241c4c057a3ce6366e5d4a9fb0e0c2d116","_id":"rd@1.1.1","_shasum":"2842d0de62084f12f419dcb0873c49d07323d37b","_from":".","_npmVersion":"3.10.10","_nodeVersion":"6.11.2","_npmUser":{"name":"leizongmin","email":"leizongmin@gmail.com"},"dist":{"shasum":"2842d0de62084f12f419dcb0873c49d07323d37b","size":5344,"noattachment":false,"key":"/rd/-/rd-1.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/rd/download/rd-1.1.1.tgz"},"maintainers":[{"name":"leizongmin","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rd-1.1.1.tgz_1502863024150_0.10274985292926431"},"directories":{},"_cnpmcore_publish_time":"2021-12-19T11:51:17.930Z","publish_time":1502863024397,"_cnpm_publish_time":1502863024397},"1.1.0":{"name":"rd","version":"1.1.0","description":"Read all directory recursively 列出（遍历）目录下的所有文件，包括子目录","main":"index.js","typings":"index.d.ts","files":["index.js","index.d.ts"],"scripts":{"test":"npm run lint && mocha -t 5000","test-cov":"istanbul cover _mocha --report lcovonly -- -t 5000 -R spec && cat ./coverage/lcov.info | coveralls","lint":"eslint . --fix","prepublish":"npm run lint"},"repository":{"type":"git","url":"git+https://github.com/leizongmin/node-rd.git"},"keywords":["directory","recursively"],"author":{"name":"Zongmin Lei","email":"leizongmin@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/leizongmin/node-rd/issues"},"homepage":"https://github.com/leizongmin/node-rd#readme","devDependencies":{"mocha":"^3.1.2","coveralls":"^2.11.14","eslint":"^3.8.1","eslint-config-lei":"0.0.14","eslint-plugin-promise":"^3.3.0","istanbul":"^0.4.5"},"dependencies":{"@types/node":"^8.0.20"},"gitHead":"b4f4896da23984dfd42a76ed7014cf97f62814bd","_id":"rd@1.1.0","_shasum":"9d8421b8d2da19a2629dfabe5732362b31a25e5c","_from":".","_npmVersion":"3.10.10","_nodeVersion":"6.11.2","_npmUser":{"name":"leizongmin","email":"leizongmin@gmail.com"},"dist":{"shasum":"9d8421b8d2da19a2629dfabe5732362b31a25e5c","size":5338,"noattachment":false,"key":"/rd/-/rd-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/rd/download/rd-1.1.0.tgz"},"maintainers":[{"name":"leizongmin","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rd-1.1.0.tgz_1502705978860_0.9497295506298542"},"directories":{},"_cnpmcore_publish_time":"2021-12-19T11:51:17.059Z","publish_time":1502705979389,"_cnpm_publish_time":1502705979389},"1.0.0":{"name":"rd","version":"1.0.0","description":"Read all directory recursively 列出（遍历）目录下的所有文件，包括子目录","main":"index.js","files":["index.js"],"scripts":{"test":"npm run lint && mocha -t 5000","test-cov":"istanbul cover _mocha --report lcovonly -- -t 5000 -R spec && cat ./coverage/lcov.info | coveralls","lint":"eslint . --fix","prepublish":"npm run lint"},"repository":{"type":"git","url":"git+https://github.com/leizongmin/node-rd.git"},"keywords":["directory","recursively"],"author":{"name":"Zongmin Lei","email":"leizongmin@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/leizongmin/node-rd/issues"},"homepage":"https://github.com/leizongmin/node-rd#readme","devDependencies":{"mocha":"^3.1.2","coveralls":"^2.11.14","eslint":"^3.8.1","eslint-config-lei":"0.0.14","eslint-plugin-promise":"^3.3.0","istanbul":"^0.4.5"},"gitHead":"f7cc170cc3be6f3d98634b1f9acdeae6d929d6e4","_id":"rd@1.0.0","_shasum":"ade444a2cbaaa0016efea7d3f0aad32498695f69","_from":".","_npmVersion":"3.10.8","_nodeVersion":"6.9.1","_npmUser":{"name":"leizongmin","email":"leizongmin@gmail.com"},"dist":{"shasum":"ade444a2cbaaa0016efea7d3f0aad32498695f69","size":4776,"noattachment":false,"key":"/rd/-/rd-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/rd/download/rd-1.0.0.tgz"},"maintainers":[{"name":"leizongmin","email":""}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/rd-1.0.0.tgz_1477554267929_0.6245713555254042"},"directories":{},"_cnpmcore_publish_time":"2021-12-19T11:51:16.192Z","publish_time":1477554271348,"_cnpm_publish_time":1477554271348},"0.0.2":{"name":"rd","main":"./lib/index.js","version":"0.0.2","description":"Read all directory recursively 列出（遍历）目录下的所有文件，包括子目录","author":{"name":"leizongmin","email":"leizongmin@gmail.com","url":"http://ucdok.com"},"repository":{"type":"git","url":"git://github.com/leizongmin/node-rd.git"},"engines":{"node":">= 0.6.0"},"devDependencies":{"mocha":">= 1.2","should":"~1.2.2"},"scripts":{"test":"mocha -t 5000"},"bugs":{"url":"https://github.com/leizongmin/node-rd/issues"},"_id":"rd@0.0.2","dist":{"shasum":"883ab18b8f4f8dcbbff4dc7b6fbb4373f505196a","size":5987,"noattachment":false,"key":"/rd/-/rd-0.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/rd/download/rd-0.0.2.tgz"},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"leizongmin","email":"leizongmin@gmail.com"},"maintainers":[{"name":"leizongmin","email":""}],"directories":{},"_cnpmcore_publish_time":"2021-12-19T11:51:15.339Z","publish_time":1394352361353,"_cnpm_publish_time":1394352361353},"0.0.1":{"name":"rd","main":"./lib/index.js","version":"0.0.1","description":"Read all directory recursively 列出（遍历）目录下的所有文件，包括子目录","author":{"name":"leizongmin","email":"leizongmin@gmail.com","url":"http://ucdok.com"},"repository":{"type":"git","url":"git://github.com/leizongmin/node-rd.git"},"engines":{"node":">= 0.6.0"},"devDependencies":{"mocha":">= 1.2","should":"~1.2.2"},"scripts":{"test":"mocha -t 5000"},"_id":"rd@0.0.1","dist":{"shasum":"877218a8c342aaa32400c812359d2f77b13d030c","size":4035,"noattachment":false,"key":"/rd/-/rd-0.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/rd/download/rd-0.0.1.tgz"},"_npmVersion":"1.1.65","_npmUser":{"name":"leizongmin","email":"leizongmin@gmail.com"},"maintainers":[{"name":"leizongmin","email":""}],"directories":{},"_cnpmcore_publish_time":"2021-12-19T11:51:14.490Z","publish_time":1372308044038,"_cnpm_publish_time":1372308044038}},"readme":"[![NPM version][npm-image]][npm-url]\n[![build status][travis-image]][travis-url]\n[![Test coverage][coveralls-image]][coveralls-url]\n[![David deps][david-image]][david-url]\n[![node version][node-image]][node-url]\n[![npm download][download-image]][download-url]\n[![npm license][license-image]][download-url]\n\n[npm-image]: https://img.shields.io/npm/v/rd.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/rd\n[travis-image]: https://img.shields.io/travis/leizongmin/node-rd.svg?style=flat-square\n[travis-url]: https://travis-ci.org/leizongmin/node-rd\n[coveralls-image]: https://img.shields.io/coveralls/leizongmin/node-rd.svg?style=flat-square\n[coveralls-url]: https://coveralls.io/r/leizongmin/node-rd?branch=master\n[david-image]: https://img.shields.io/david/leizongmin/node-rd.svg?style=flat-square\n[david-url]: https://david-dm.org/leizongmin/node-rd\n[node-image]: https://img.shields.io/badge/node.js-%3E=_0.6-green.svg?style=flat-square\n[node-url]: http://nodejs.org/download/\n[download-image]: https://img.shields.io/npm/dm/rd.svg?style=flat-square\n[download-url]: https://npmjs.org/package/rd\n[license-image]: https://img.shields.io/npm/l/rd.svg\n\n# rd\n\n列出（遍历）目录下的所有文件，包括子目录（支持 TypeScript）\n\n## 安装\n\n```bash\nnpm install rd --save\n```\n\n## API列表\n\n说明：\n\n+ `read` 开头表示返回数组结果\n+ `each` 开头表示每发现一个文件均调用回调函数 `findOne`\n+ `Sync` 结尾表示是同步函数，其他表示异步函数\n\n可用的API（详细用法可参考 `test/test.js` ）：\n\n+ `read(dir, [threads], callback)`\n+ `readFilter(dir, pattern, [threads], callback)`\n+ `readFile(dir, [threads], callback)`\n+ `readFileFilter(dir, pattern, [threads], callback)`\n+ `readDir(dir, [threads], callback)`\n+ `readDirFilter(dir, pattern, [threads], callback)`\n+ `each(dir, findOne, [threads], callback)`\n+ `eachFilter(dir, pattern, [threads], findOne, callback)`\n+ `eachFile(dir, [threads], findOne, callback)`\n+ `eachFileFilter(dir, pattern, [threads], findOne, callback)`\n+ `eachDir(dir, [threads], findOne, callback)`\n+ `eachDirFilter(dir, pattern, [threads], findOne, callback)`\n\n说明：\n\n+ 以上所有函数均提供同步版本，如 `read` 对应的同步版本为 `readSync`；相应的 `callback` 改为直接 `return` 返回值；\n+ `threads` 参数表示并发数量，为可选参数，默认为1；同步版本没有此参数；\n\n`findOne` 回调函数格式：\n\n```javascript\nfunction findOne(filename, stats) {\n  // filename 是当前文件的完整路径\n  // stats 是使用 fs.Stats 对象\n}\n```\n\n`callback` 回调函数格式：\n\n```javascript\nfunction callback(err, list) {\n  // 如果出错，err为出错信息\n  // each系列函数没有list参数\n  // read系列函数list为完整文件名的列表\n}\n```\n\n`pattern` 参数格式：\n\n+ 正则表达式\n+ 函数\n\n```javascript\nfunction pattern(filename) {\n  // filename 是当前文件的完整路径\n  // 返回 true 表示该文件名符合条件\n}\n```\n\n## 简单示例\n\n```javascript\nvar rd = require('rd');\n\n// 异步列出目录下的所有文件\nrd.read('/tmp', function (err, files) {\n  if (err) throw err;\n  // files是一个数组，里面是目录/tmp目录下的所有文件（包括子目录）\n});\n\n// 同步列出目录下的所有文件\nvar files = rd.readSync('/tmp');\n\n// 异步遍历目录下的所有文件\nrd.each('/tmp', function (f, s, next) {\n  // 每找到一个文件都会调用一次此函数\n  // 参数s是通过 fs.stat() 获取到的文件属性值\n  console.log('file: %s', f);\n  // 必须调用next()才能继续\n  next();\n}, function (err) {\n  if (err) throw err;\n  // 完成\n});\n\n// 同步遍历目录下的所有文件\nrd.eachSync('/tmp', function (f, s) {\n  // 每找到一个文件都会调用一次此函数\n  // 参数s是通过 fs.stat() 获取到的文件属性值\n  console.log('file: %s', f);\n});\n\n// 同步遍历目录下的所有js文件\nrd.eachFileFilterSync('/path', /\\.js$/, function (f, s) {\n  console.log(f);\n});\n```\n\n## License\n\n```text\nCopyright (c) 2013-2018 Zongmin Lei <leizongmin@gmail.com>\nhttp://ucdok.com\n\nThe MIT License\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n```","_attachments":{},"homepage":"https://github.com/leizongmin/node-rd#readme","bugs":{"url":"https://github.com/leizongmin/node-rd/issues"},"license":"MIT"}