{"name":"totalist","version":"3.0.0","repository":{"type":"git","url":"git+https://github.com/lukeed/totalist.git"},"description":"A tiny (195B to 220B) utility to recursively list all (total) files in a directory","module":"dist/index.mjs","main":"dist/index.js","types":"index.d.ts","exports":{".":{"import":"./dist/index.mjs","require":"./dist/index.js"},"./sync":{"import":"./sync/index.mjs","require":"./sync/index.js"}},"license":"MIT","author":{"name":"Luke Edwards","email":"luke.edwards05@gmail.com","url":"https://lukeed.com"},"engines":{"node":">=6"},"keywords":["list","recursive","files","glob","tree"],"scripts":{"build":"bundt","test":"uvu -r esm test -i fixtures"},"modes":{"sync":"src/sync.js","default":"src/async.js"},"devDependencies":{"bundt":"1.1.1","esm":"3.2.25","uvu":"0.3.3"},"gitHead":"1a82bf3dfb9e25bf4e0341d9be10218f0f7194d6","bugs":{"url":"https://github.com/lukeed/totalist/issues"},"homepage":"https://github.com/lukeed/totalist#readme","_id":"totalist@3.0.0","_nodeVersion":"16.13.0","_npmVersion":"8.1.0","dist":{"integrity":"sha512-eM+pCBxXO/njtF7vdFsHuqb+ElbxqtI4r5EAvk6grfAFyJ6IvWlSkfZ5T9ozC6xWw3Fj1fGoSmrl0gUs46JVIw==","shasum":"4ef9c58c5f095255cdc3ff2a0a55091c57a3a1bd","tarball":"http://registry-npm.ywwl.com/totalist/download/totalist-3.0.0.tgz","fileCount":9,"unpackedSize":7392,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh5c0WCRA9TVsSAnZWagAADtgP/2oF4k/bfVIofi1mYrPH\negQv0AT3xo74Ud6kFXVXY/Ou8mRzDDVrkxysPSGdt8ZSey/eGVmBxix4idPJ\n8Ba2G60iqNanS5alTDLvoJM8O+SJPmMJ3T/bzj61QjtKFbA07dz8JE5uR/4T\nLFhI8siuyZ6JjR5n3J5Wofy3o+MlqbAaO/WmOpPW8ZcomJWHXiXcSfZrj0w7\nQRU09ZdMs9iSOc/JHNjoFYYpYGK8nSaZA35vAJUY6Br4+YMmSZ6CZmxo9LrT\nGVbBR5wcJ6fRGnDrAwRJD5hM32Wz6vTkaHse9s2Wum/IpLqUaJAdy4FIffSW\nzuG83t2VglbzP4Nrowi012f4IjfXALDuI+EYf2mGinmlVGbnTetJo/QXkjXz\nhCc7+nDFibvs/nEkFivbwoEHuz7pLy7TAVWJ7fkK0/IMdrEUO4BG9VKr0uF9\nJfwaipZB2eErECOTV2AOpL/Y+WE0W+JqSCQR5Ie78QVRF9ggotSG+Ld5LTJ9\nXnsJRgxCjbyo1jgEnk+84CfkMbk48sLDx5OyQLsumxIJyiHey9ZHW5wDeUd9\nK/i3iTLKYRth3gCUSRHB0hY1Xc7Pmzm7hWGu2fHFn70bGEaN/LJoSmot2l1M\nhc4X62b3GC2mQmqC7TyzRSGHoLnYX8HNo+2ymF6XBKXjatHj6VjNNkpULQKg\njRL9\r\n=OW6p\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAKUoaOOpVdHcDVUzUW6f+1vNiis4X9BGq3RZCUZsh1/AiEA0nKHfxAUmJAFPxVHFR0lTvS6yu8euBDu+YM0qqxp/+8="}],"size":3073,"noattachment":false,"key":"/totalist/-/totalist-3.0.0.tgz"},"_npmUser":{"name":"lukeed","email":"luke@lukeed.com"},"directories":{},"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/totalist_3.0.0_1642450197882_0.017623012021366957"},"_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":1642450198038,"_cnpm_publish_time":1642450198038,"dist-tags":{"latest":"3.0.1"}}