{"name":"klaw-sync","version":"8.0.0","description":"Recursive, synchronous, and fast file system walker","main":"klaw-sync.js","repository":{"type":"git","url":"git+https://github.com/manidlou/node-klaw-sync.git"},"keywords":["fs","walk","walker","walk-sync","klaw","readdir-sync"],"author":{"name":"Mani Maghsoudlou"},"license":"MIT","bugs":{"url":"https://github.com/manidlou/node-klaw-sync/issues"},"homepage":"https://github.com/manidlou/node-klaw-sync#readme","dependencies":{"graceful-fs":"^4.1.11"},"devDependencies":{"benchmark":"^2.1.4","fs-extra":"^11.3.5","memfs":"^4.57.2","mkp":"^1.0.1","mocha":"^11.7.5","standard":"^17.1.2","walk-sync":"^4.0.2"},"standard":{"env":["mocha"]},"scripts":{"lint":"standard","lint:fix":"standard --fix","unit":"mocha","test":"npm run lint && npm run unit","benchmark":"node ./benchmark/bm.js"},"gitHead":"615cbb4809b2bbbe9578223dc3f97881974212f8","_id":"klaw-sync@8.0.0","_nodeVersion":"24.14.0","_npmVersion":"11.9.0","dist":{"integrity":"sha512-43JUng1ueb4U//VKdDl4zvvu8gak6mo4AYv0EOifPJXivVa26iwq8390DEs0PoGEsL+KtVd9XFEbWpwuszB1cg==","shasum":"47b12564c393d30875f4be875b4237c53eb7fb88","tarball":"http://registry-npm.ywwl.com/klaw-sync/download/klaw-sync-8.0.0.tgz","fileCount":5,"unpackedSize":11284,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDBXv63P+v3tBcoaYXinA82HKbyUDkm9rpLzYdk0af+VwIgbP3aAvUlqjp5zNDl/rM1OY/F0IDVwBDK+4JbMIym390="}],"size":4590,"noattachment":false,"key":"/klaw-sync/-/klaw-sync-8.0.0.tgz"},"_npmUser":{"name":"manidlou","email":"manidlou@gmail.com"},"directories":{},"maintainers":[{"name":"manidlou","email":"manidlou@gmail.com"},{"name":"vic3king","email":"vic3coorp@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/klaw-sync_8.0.0_1781865072529_0.8283130137246242"},"_hasShrinkwrap":false,"readme":"node-klaw-sync\n==============\n\n[![npm Package](https://img.shields.io/npm/v/klaw-sync.svg?style=flat-square)](https://www.npmjs.com/package/klaw-sync)\n[![Build Status](https://travis-ci.org/manidlou/node-klaw-sync.svg?branch=master)](https://travis-ci.org/manidlou/node-klaw-sync)\n[![windows Build status](https://ci.appveyor.com/api/projects/status/braios34k6qw4h5p/branch/master?svg=true)](https://ci.appveyor.com/project/manidlou/node-klaw-sync/branch/master)\n[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg?style=flat-square)](https://standardjs.com)\n[![Known Vulnerabilities](https://snyk.io/test/npm/klaw-sync/badge.svg?style=flat-square)](https://snyk.io/test/npm/klaw-sync)\n\n`klaw-sync` is a Node.js recursive and fast file system walker, which is the synchronous counterpart of [klaw](https://github.com/jprichardson/node-klaw). It lists all files and directories inside a directory recursively and returns an array of objects that each object has two properties: `path` and `stats`. `path` is the full path of the file or directory and `stats` is an instance of [fs.Stats](https://nodejs.org/api/fs.html#fs_class_fs_stats).\n\nInstall\n-------\n\n    npm i klaw-sync\n\nUsage\n-----\n\n### klawSync(directory[, options])\n\n- `directory` `<String>`\n- `options` `<Object>` (optional)\n  - `nodir` `<Boolean>` default: `undefined`\n    - return only files (ignore directories).\n  - `nofile` `<Boolean>` default: `undefined`\n    - return only directories (ignore files).\n  - `depthLimit`: `<Number>` default: `-1`\n    - the number of times to recurse before stopping. `-1` for unlimited.\n  - `fs`: `<Object>` default: `graceful-fs`\n    - custom `fs`, useful when mocking `fs` object.\n  - `filter` `<Function>` default: `undefined`\n    - function that gets one argument `fn({path: '', stats: {}})` and returns true to include or false to exclude the item.\n  - `traverseAll` `<Boolean>` default: `undefined`\n    - traverse all subdirectories, regardless of `filter` option. This can be useful when you have a filter function and still want to traverse all subdirectories even if your filter function doesn't pass for some directories.\n- **Return:** `<Array<Object>>` `[{path: '', stats: {}}]`\n\nExamples\n--------\n\n```js\nconst klawSync = require('klaw-sync')\n\nconst paths = klawSync('/some/dir')\n// paths = [{path: '/some/dir/dir1', stats: {}}, {path: '/some/dir/file1', stats: {}}]\n```\n\n_**catch error**_\n\n```js\nconst klawSync = require('klaw-sync')\n\nlet paths\ntry {\n  paths = klawSync('/some/dir')\n} catch (er) {\n  console.error(er)\n}\nconsole.dir(paths)\n```\n\n_**files only**_\n\n```js\nconst klawSync = require('klaw-sync')\n\nconst files = klawSync('/some/dir', {nodir: true})\n// files = [{path: '/some/dir/file1', stats: {}}, {path: '/some/dir/file2', stats: {}}]\n```\n\n_**directories only**_\n\n```js\nconst klawSync = require('klaw-sync')\n\nconst dirs = klawSync('/some/dir', {nofile: true})\n// dirs = [{path: '/some/dir/dir1', stats: {}}, {path: '/some/dir/dir2', stats: {}}]\n```\n\n_**ignore hidden directories**_\n\n\n```js\nconst path = require('path')\nconst klawSync = require('klaw-sync')\n\nconst filterFn = item => {\n  const basename = path.basename(item.path)\n  return basename === '.' || basename[0] !== '.'\n}\n\nconst paths = klawSync('/some/dir', { filter: filterFn})\n```\n\n_**filter based on stats**_\n\nHere `traverseAll` option is required since we still want to read all subdirectories even if they don't pass the `filter` function, to see if their contents do pass the `filter` function.\n\n```js\nconst klawSync = require('klaw-sync')\n\nconst refTime = new Date(2017, 3, 24).getTime()\nconst filterFn = item => item.stats.mtime.getTime() > refTime\n\nconst paths = klawSync('/some/dir', { traverseAll: true, filter: filterFn })\n```\n\nRun tests\n---------\n\nlint: `npm run lint`\n\nunit test: `npm run unit`\n\nlint & unit: `npm test`\n\nbenchmark: `npm run benchmark`\n\nPerformance compare to other similar modules\n-----------------------------------------------\n\nRunning some [benchmark](https://github.com/bestiejs/benchmark.js) tests on these modules:\n\n- `klaw-sync`\n- [walk-sync](https://github.com/joliss/node-walk-sync)\n\n(as of Jan 25, 2017) `klaw-sync` is the fastest module!\n\n##### results (tested on Ubuntu 18.04, Intel(R) Core(TM) i7-2630QM CPU @ 2.00GHz, 8 CPUs, 8g RAM, node v10.9.0)\n\n```bash\nRunning benchmark tests..\n\nroot dir length: 1110\nwalk-sync x 80.71 ops/sec ±1.42% (72 runs sampled)\nklaw-sync x 160 ops/sec ±1.17% (79 runs sampled)\nFastest is klaw-sync\n\nroot dir length: 11110\nwalk-sync x 7.55 ops/sec ±3.39% (23 runs sampled)\nklaw-sync x 14.95 ops/sec ±0.27% (40 runs sampled)\nFastest is klaw-sync\n\nroot dir length: 111110\nwalk-sync x 0.63 ops/sec ±6.92% (6 runs sampled)\nklaw-sync x 1.22 ops/sec ±0.96% (7 runs sampled)\nFastest is klaw-sync\n```\n\nContributing\n-----------\n\n1. Fork the repository\n2. Clone your forked version\n   ```bash\n   git clone https://github.com/YOUR_USERNAME/node-klaw-sync.git\n   ```\n3. Create a new branch for your changes\n   ```bash\n   git checkout -b feature/your-feature-name\n   ```\n4. Make your changes and commit them\n5. Push to your fork\n   ```bash\n   git push origin feature/your-feature-name\n   ```\n6. Create a Pull Request from your fork to the original repository\n\nBefore submitting a PR:\n- Ensure tests pass: `npm test`\n- Add tests for new features\n- Follow the existing code style\n\nLicense\n-------\n\nLicensed under MIT\n","publish_time":1781865072668,"_cnpm_publish_time":1781865072668,"dist-tags":{"latest":"8.0.0"}}