{"name":"totalist","version":"1.0.0","repository":{"type":"git","url":"git+https://github.com/lukeed/totalist.git"},"description":"A tiny (195B to 211B) 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"},"keywords":["list","recursive","files","glob","tree"],"scripts":{"build":"node bin","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":"6e620cfa691a76cc7ac6ef7fc3e49136d7f6f874","bugs":{"url":"https://github.com/lukeed/totalist/issues"},"homepage":"https://github.com/lukeed/totalist#readme","_id":"totalist@1.0.0","_npmVersion":"6.4.1","_nodeVersion":"10.13.0","_npmUser":{"name":"lukeed","email":"luke@lukeed.com"},"dist":{"integrity":"sha512-K+Axow2A+XxeORODPqpc3qQB1F3m0KzCaQgviWUjoNJTvM0yJ2ABVtkyaEdrE5fNPpZwD2EN1X/tGHQgL8araA==","shasum":"a8d5c222af3bb7cfc387c850261b4367e01cd74d","tarball":"http://registry-npm.ywwl.com/totalist/download/totalist-1.0.0.tgz","fileCount":9,"unpackedSize":7044,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdroOSCRA9TVsSAnZWagAAHSQP/2+4xL+17FhyFKANMJyx\n5y2QyMG1Y0++q69lho6p3AT2QelWY71neHlgzPlFJmFnDt609apQ3FFtss8s\nU2hnKKD5HHWT6l7hxDXG/hWZTs5NkqLJ1/KT5VvHrrigp8Z8/7anjGQdL6yg\nA8E1LSglgPlEo5mq9BiE6n1noNBQsm+BO08sTDimag5Kk6eH7YYnrFlFn8zX\ncZ+gV94hcfherQClczPpoqIFYvCBI6sN0eK7jD4WhvCk8UVOcpjup9RTPCb0\nUjJHXEA7XK7WWsfjeUrKPAYxDYFsmIA2UvRQugGZrFpXJSZgctnDWeQ+zysf\nnWy6d2MWpX27FxmyKm2c7Lr2Yk6+0Lk69kiQRAIvYaiHirxFqnueE+JhzLiY\nqMokYZsklOCxdRt9THzSToGQNf7MkP47ugbw3po2OS4UubSj4Cb+YtZ+buOm\n9UhnH1XT2NAo3IOaxSQeBuBAarboWvxV1uS+CsJsAfs9gORO3Zm2vlkI8D6Z\nWvY+9g/1cYUFjStzGkJCtiV68KrLnnmg+qyRtGYCUcQmeLBeDqi9twOm/26T\nbtQjinlICUY38F/oWidSNsp9/nzR5PiT4+fuqlW86/F+b00pUDanR2xJ96pM\nPT87Chif5VK+LMr+KxLvadcq3lPlqloiNGVsv0QRR65XmTUzBk7MdTD+hLTA\nYsWB\r\n=nK5x\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGuQcuzs9YaF3U2mld9pRcslXkL9T1tvdxPd2Lk3H3dJAiEA//wLighoYmebvcpPrSPu7WWbcMP2RC7cn5iirLt4J1k="}],"size":3022,"noattachment":false,"key":"/totalist/-/totalist-1.0.0.tgz"},"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/totalist_1.0.0_1571718034198_0.7194270173873631"},"_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":1571718034416,"_cnpm_publish_time":1571718034416,"dist-tags":{"latest":"3.0.1"}}