{"name":"klaw-sync","version":"5.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":"^5.0.0","memory-fs":"^0.4.1","mkp":"^1.0.1","mocha":"^5.1.1","standard":"^11.0.1","walk-sync":"^0.3.3"},"standard":{"env":["mocha"]},"scripts":{"lint":"standard","unit":"mocha","test":"npm run lint && npm run unit","benchmark":"node ./benchmark/bm.js"},"gitHead":"6e3500d485d51c462132880e780ae4d0db07ce0e","_id":"klaw-sync@5.0.0","_npmVersion":"6.4.1","_nodeVersion":"10.9.0","_npmUser":{"name":"manidlou","email":"manidlou@gmail.com"},"dist":{"integrity":"sha512-z1Gj2e9FBU1+OVQqp8vgPWmusPFXqfiGL3NRSmOkXfpbKO3HsvXX0SwZWlpGZp6kheQwhZfE2TNC8RLmD4NwSQ==","shasum":"b8db1249f96a82751c311ee8a626a319db119904","tarball":"http://registry-npm.ywwl.com/klaw-sync/download/klaw-sync-5.0.0.tgz","fileCount":5,"unpackedSize":9733,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbkMd0CRA9TVsSAnZWagAAM4YP/0nFxVWqKDHaI9jrOuB7\n2DzmAfwZ9Qs20McMKfSRSAJL/pN8N9TFyoqJbaoJTq6KbcZW24A279nghrdf\nfk6Vt2YO7rldXkUJbb7l/oVhBJovjzAV721Utw8GNtkOkRBPRK2kOy3exZDT\nxzdjuyN9q6osGAVj+57iDUdisQ23yixODQQRJMqv4yL4AUqt/t8bpIItRCTN\n9QyMBf0/Bh7ZWr8cDE6YMTo7B3O/aLCcXHMUANYoeY13s/C/0iNe9wsS/kZe\nyPedbWyhzOamYYEKaBpSzZj2AAz+Qv65z/amO8JqBB7gd6kuY7WWfO9nYmZb\nABguqLKbMYGsjSIhB/hwEWIxBFLxoWGnLlEYxjot8rFHdl8s/J7pFQ6LRxQP\nrK/upBx+JgcrLy2z+9v363v7l67hgM7wxfzNz+VNRfitQwzMZjwBA17g8AN4\nUbotb7ARSxs52bFXoXhKDvvbMUvPi+N2Ip9oMj8YeUrxSZkP4P/f7USp+ZDm\nnLwCs6KteERa6MrDsS0aLQ3sOtTKnpA5/68sL0dBhDFRUZAFQft1CiEoz9ce\nyNA7C6OSKWICoS+PVBGI6aPdMwjY4CzRPmyxLE4bzJVXXEsDV1RliU5vag/w\nWHGG9AavK/wlNw94L+375rewE5w+Lmaf1dhc03m/lzim2QKgxCVx4v/esurL\ncgCA\r\n=xdmY\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBBdNWiWSfyAp2KdyCmVGYnp+N0xRFL0dRTmUhCaEzaQAiARwmWPstiW1mU3PRCFd8/kxVy0QoqL3F1Xb4BMjSWtQQ=="}],"size":4101,"noattachment":false,"key":"/klaw-sync/-/klaw-sync-5.0.0.tgz"},"maintainers":[{"name":"manidlou","email":"manidlou@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/klaw-sync_5.0.0_1536214899709_0.7009992884725926"},"_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) _all options are `false` by default_\n  - `nodir` `<Boolean>`\n    - return only files (ignore directories).\n  - `nofile` `<Boolean>`\n    - return only directories (ignore files).\n  - `depthLimit`: `<Number>`\n    - the number of times to recurse before stopping. `-1` for unlimited.\n  - `fs`: `<Object>`\n    - custom `fs`, useful when mocking `fs` object.\n  - `filter` `<Function>`\n    - function that gets one argument `fn({path: '', stats: {}})` and returns true to include or false to exclude the item.\n  - `traverseAll` `<Boolean>`\n    - traverse all subdirectories, regardless of `filter` option. (When set to `true`, `traverseAll` produces similar behavior to the default behavior prior to v4.0.0. The current default of  `traverseAll: false` is equivalent to the old `noRecurseOnFailedFilter: true`).\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 directories 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', { 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 139 ops/sec ±2.48% (76 runs sampled)\nklaw-sync x 163 ops/sec ±1.20% (80 runs sampled)\nFastest is klaw-sync\n\nroot dir length: 11110\nwalk-sync x 13.23 ops/sec ±1.10% (37 runs sampled)\nklaw-sync x 15.10 ops/sec ±1.06% (41 runs sampled)\nFastest is klaw-sync\n\nroot dir length: 111110\nwalk-sync x 1.17 ops/sec ±2.06% (7 runs sampled)\nklaw-sync x 1.25 ops/sec ±2.10% (8 runs sampled)\nFastest is klaw-sync\n```\n\nCredit\n------\n\nSpecial thanks to:\n\n- [agnivade](https://github.com/agnivade)\n- [jprichardson](https://github.com/jprichardson)\n- [RyanZim](https://github.com/RyanZim)\n\nfor their contribution and support.\n\nLicense\n-------\n\nLicensed under MIT\n","publish_time":1536214899970,"_cnpm_publish_time":1536214899970,"dist-tags":{"latest":"8.0.0"}}