{"name":"totalist","version":"0.0.0","repository":{"type":"git","url":"git+https://github.com/lukeed/totalist.git"},"description":"A tiny (181B to 195B) utility to recursively list all (total) files in a directory","module":"dist/index.mjs","main":"dist/index.js","types":"index.d.ts","license":"MIT","author":{"name":"Luke Edwards","email":"luke.edwards05@gmail.com","url":"https://lukeed.com"},"engines":{"node":">=6"},"scripts":{"build":"node bin","pretest":"npm run build","test":"tape -r esm test/*.js | tap-spec"},"devDependencies":{"bundt":"0.4.0","esm":"3.2.25","premove":"1.0.0","tap-spec":"5.0.0","tape":"4.11.0"},"gitHead":"c8d725411f03e329085fd100522dd6abe3e4ea0b","bugs":{"url":"https://github.com/lukeed/totalist/issues"},"homepage":"https://github.com/lukeed/totalist#readme","_id":"totalist@0.0.0","_npmVersion":"6.4.1","_nodeVersion":"10.13.0","_npmUser":{"name":"lukeed","email":"luke@lukeed.com"},"dist":{"integrity":"sha512-lS80dy0XsMCmCfMQ73DuXi59xf1tVg5reyYGQI8m+MwxmkTKsd1T+jmFgS4wjKoryXG2GoIi/1sB7bTKf6Z11A==","shasum":"ee2214c2135168083daf0d599538d3dd5b75f93d","tarball":"http://registry-npm.ywwl.com/totalist/download/totalist-0.0.0.tgz","fileCount":9,"unpackedSize":6782,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdrk48CRA9TVsSAnZWagAAgOkP/3Gh+kxNdhqkcXMhK4PA\n1YSuFhdK6moRbnpcPQTwIC6QUQH5V5VAyoXVmrvAZ9eQBg4WA9YM7StByP4O\n8Bdhyj1e48I3eVRZDAIHL4W2IupNLShhkiEmCGdp7lFQJed2IrWn20x6ffdN\nzKBtYuw5j04BnggJnRBY5X/gfI5T746YPE7N1dA4/RCXjfkptmDf8aDyAmq8\nFZ0vJHNaJ/gIW3TMTJXTMuzJrCDW30U6VJSyT45IkQXa3vktOEyK2CXZmybD\nptItcolQRDnkbovBZugDji3xBmrXSPVLkqOIWM/kva+YE0duMFOwje/yHUVu\n9DPJglg26H2fF4w5kN37DYXv0/fvyQ4b0TZfgVwmmk15HJSFCXoHYLKIB5sN\nfHmly/PZNlfV9r+XdLPB1ybSENebzBaRS9+bzIAAHtw8dxJrKxqRZQHrFTf6\nz1OTCi0//vGXTnO/DJ5s5jL8WNsEMpMknJuiTsKZvS+km7X5eOxBMHLRRJBY\n08nJehcStJspzbx4qgfgT3k/SmKf4gWKLgAo0CVyYM8yIAHx1abEc1AeR7qE\n0Pa716otuXTtfT2QMf9314uZUHlWAK1oqWUDLE5LfzQwtIOg9MKi5O9+31bb\nnLruV9FzDWVGAYod/Olit4iA8rbEPKnvSV0/Ns1tBSQ9Y3dFLOf6RSJvyIGq\nq6o2\r\n=jeUj\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCOd1vOlwTG2z2KKuQFzuVvGLspZXCOez6ylkFQg/YtCAIgKlhJH00LBfYRsrubjrgkD8qPDOt5ixktgxmbjFpDoB0="}],"size":2896,"noattachment":false,"key":"/totalist/-/totalist-0.0.0.tgz"},"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/totalist_0.0.0_1571704379901_0.727980550891538"},"_hasShrinkwrap":false,"readme":"# totalist [![build status](https://badgen.now.sh/github/status/lukeed/totalist)](https://github.com/lukeed/totalist/actions) [![codecov](https://badgen.now.sh/codecov/c/github/lukeed/totalist)](https://codecov.io/gh/lukeed/totalist)\n\n> A tiny (195B to 224B) utility to recursively list all (total) files in a directory\n\nTraverse a directory recursively, running a function for **every file** found.\n\nWith this module, you easily apply custom logic to decide which file(s) to process without worrying about accidentally accessing a directory or making repeat `fs.Stats` requests.\n\n## Install\n\n```\n$ npm install --save totalist\n```\n\n\n## Modes\n\nThere are two \"versions\" of `totalist` available:\n\n#### \"async\"\n> **Node.js:** >= 8.x<br>\n> **Size (gzip):** 220 bytes<br>\n> **Availability:** [CommonJS](https://unpkg.com/totalist/dist/index.js), [ES Module](https://unpkg.com/totalist/dist/index.mjs)\n\nThis is the primary/default mode. It makes use of `async`/`await` and [`util.promisify`](https://nodejs.org/api/util.html#util_util_promisify_original).\n\n#### \"sync\"\n> **Node.js:** >= 6.x<br>\n> **Size (gzip):** 195 bytes<br>\n> **Availability:** [CommonJS](https://unpkg.com/totalist/sync/index.js), [ES Module](https://unpkg.com/totalist/sync/index.mjs)\n\nThis is the opt-in mode, ideal for scenarios where `async` usage cannot be supported.\n\n\n## Usage\n\n***Selecting a Mode***\n\n```js\n// import via npm module\nimport { totalist } from 'totalist';\nimport { totalist } from 'totalist/sync';\n```\n\n***Example Usage***\n\n```js\nimport { totalist } from 'totalist/sync';\n\nconst styles = new Set();\nconst scripts = new Set();\n\ntotalist('src', (name, abs, stats) => {\n  if (/\\.js$/.test(name)) {\n    scripts.add(abs);\n    if (stats.size >= 100e3) {\n      console.warn(`[WARN] \"${name}\" might cause performance issues (${stats.size})`);\n    }\n  } else if (/\\.css$/.test(name)) {\n    styles.add(abs);\n  }\n});\n\nconsole.log([...scripts]);\n//=> [..., '/Users/lukeed/.../src/path/to/example.css', ...]\n```\n\n\n## API\n\n### totalist(dir, callback)\nReturns: `void`\n\n> **Important:** The \"async\" usage must be `await`ed or included within a Promise chain.\n\n#### dir\nType: `string`<br>\nRequired: `true`\n\nThe directory to traverse.\n\nThis may be a relative _or_ an absolute path.\n\n> **Note**: Node.js will assume a relative path is meant to be resolved from the current location (`process.cwd()`).\n\n#### callback\nType: `Function`<br>\nRequired: `true`\n\nThe callback function to run for _every_ file.\n\nThe function receives three parameters:\n\n##### relPath\nType: `String`<br>\nThe path _relative to_ the initial `dir` value you provided.\n\n##### absPath\nType: `String`<br>\nThe absolute path of the file.\n\n##### stats\nType: `fs.Stats`<br>\nThe [`fs.Stats`](https://nodejs.org/api/fs.html#fs_class_fs_stats) object for the file.\n\n\n## License\n\nMIT © [Luke Edwards](https://lukeed.com)\n","publish_time":1571704380036,"_cnpm_publish_time":1571704380036,"dist-tags":{"latest":"3.0.1"}}