{"name":"klaw-sync","version":"6.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":"cab813f8a9df1a10330802c9a56d856d4868b044","_id":"klaw-sync@6.0.0","_npmVersion":"6.4.1","_nodeVersion":"10.9.0","_npmUser":{"name":"manidlou","email":"manidlou@gmail.com"},"dist":{"integrity":"sha512-nIeuVSzdCCs6TDPTqI8w1Yre34sSq7AkZ4B3sfOBbI2CgVSB4Du4aLQijFU2+lhAFCwt9+42Hel6lQNIv6AntQ==","shasum":"1fd2cfd56ebb6250181114f0a581167099c2b28c","tarball":"http://registry-npm.ywwl.com/klaw-sync/download/klaw-sync-6.0.0.tgz","fileCount":5,"unpackedSize":10427,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbp7d+CRA9TVsSAnZWagAAOSgP/R7JJnFD2desTiv6deef\nlcqlUYWdtjirCl4yWS7xYw50sx+r89qMpdnFgTLZ5wax8gt7t1PnyMVpnrp1\npNI85OwVIeA4cy51rFeswAJhRgC9iBnNYLTzPQoC9W0nZQrWAfpT7bHN3TKa\nYeSP2gZP0E6RGcudTLA/pVuaaHyfvWHJ9Yx78avej8aQmWn1f9UdilBSQA6g\nEWWxTiNd2UArHwkUBRNKHqqcrP0eu4b4kEOdnfxFlokC2JjuCarnZzZG7h6/\nASOI41mCc3Wgfx3yHt4c14JivlxFhwO+YnBN1hRkjRtmX9AZfnNywW/WeODi\nKPpFkk7AvePsQYgrSWHOgAKKRv20/DDqYP4DkLQez9zGxKuQbaT3kZyWFAJU\nhABEHlLtGuuY6ZNIKLoMiTB99CpyQ7kipJfphyC66esCX5hc7CPAmVDHm3K7\nlfBDBzY9szNaufhCrnb3S5IPYuLi4uiN8fiHNEkRFADLPem1ZffQ853WtRBG\nUVFExI7r0hAr3n9lnFTaHt3SZeQ55UlNgIpBu+SEQaUJHv9rc8ZWKuwzMJsA\njrnjXWTXusEFZ6bpJO0pRq2Ky5Bp2+rlWQpKbU2YYK1JYoCKrkbftXpjbtL8\n5hca92NblYGb6EgmNVNAk+W28JK1fbGxQepYnf+GcoEnHXNbSKT1EN2g97I0\n6Odz\r\n=+nMG\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD5uvDnDWeEDjd1bFHobStmQdQjBE8//dme3K7Y1GHnmgIhAOdnX/gZsrW3/KaYD2kBy/54mSoj0jNadbj6eS04Lo0v"}],"size":4330,"noattachment":false,"key":"/klaw-sync/-/klaw-sync-6.0.0.tgz"},"maintainers":[{"name":"manidlou","email":"manidlou@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/klaw-sync_6.0.0_1537718141401_0.8576057938100381"},"_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":1537718141531,"_cnpm_publish_time":1537718141531,"dist-tags":{"latest":"8.0.0"}}