{"_id":"scorta","_rev":"2-bac88343bd5d17c9d3bd4e1ab0c02f34","name":"scorta","dist-tags":{"latest":"1.0.0"},"versions":{"0.0.0":{"name":"scorta","version":"0.0.0","repository":{"type":"git","url":"git+https://github.com/lukeed/scorta.git"},"description":"WIP","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"},"exports":{".":{"import":"./dist/index.mjs","require":"./dist/index.js"},"./sync":{"import":"./sync/index.mjs","require":"./sync/index.js"}},"modes":{"sync":"src/sync.js","default":"src/async.js"},"engines":{"node":">=6"},"scripts":{"build":"bundt","pretest":"npm run build","test":"uvu -r esm test -i fixtures"},"keywords":["find","cache","module","directory","tmpdir"],"dependencies":{"escalade":"^3.1.0"},"devDependencies":{"bundt":"1.1.1","esm":"3.2.25","uvu":"0.3.3"},"gitHead":"42b99dadd99d1637d7d0f7e9b1d2bc8edd545fba","bugs":{"url":"https://github.com/lukeed/scorta/issues"},"homepage":"https://github.com/lukeed/scorta#readme","_id":"scorta@0.0.0","_nodeVersion":"14.12.0","_npmVersion":"6.14.8","dist":{"integrity":"sha512-ZMQLuA+6d93+cuFZtoT+3fnDkub5o2xBG/MvB88Mkm99a9+Sq/ZwjUAMUExl8Pu1jo5eZg2MQ/rWwe6zEUEwIQ==","shasum":"3b354d58e8450cb3a550428fa194525afad383a0","tarball":"https://registry.npmjs.org/scorta/-/scorta-0.0.0.tgz","fileCount":8,"unpackedSize":5991,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfelZRCRA9TVsSAnZWagAASBEP+QEinOLV/dcfj1ZEoC8Y\nnPDa33359lydX7iNa7Foez2Ml5H0sSAnMdqLqJDkZNo1IeI2gLXr1ifDPZ1m\n43JdfRJYLrWNtXiBh5+sNO4eW7ocrpz3uU6JL2YEPZxthxae004Ubo5cLU1W\n2WJifGBYkCkhF7nD0NmCY3+hskq291IE/5LMcfNCo57Lb8tB16FNj9HuK9fm\nLuVfrZCImsNa4Kv9yar2eN+3FxWtAmIYGwpROQUPmszmmP5xq4KH1WrBdvRl\nBt4kzqhdql0GCO7Rn2yr3BAkO/Z+pj2hIRzQyTD5SCelrKmi7qQoxXldJTVv\nXazE0loWup4AL9AhEwixBwzrJaMVuDMkQouXz4npb2Y8g3MA1xnbgFBgVNcy\n7mmdgp2Qz2+G/hTTYJuatbVaA9qCrLxP3iNxrCs0isNolls4NX5gTcCJeYEl\n863AUUZHPCWxbLVBiVcZQIHcE9Hj2EXiAlvOUhMvAkEKWdY2IxvSG1itr0Xt\nCV8WOmtpxCqtLDVWGPu6oOWahGyEKfSz8Np5pZDPWT7kjWVOaF8gPNP8UMOP\nCvliJFBYGNHVeiR0cs+kqcIXlVlmlVvtaqwhY7wFNAVgGYTJ3ENLsjZfnjPa\nUv3gQApAa0Y4BkZtReSVwgKeq91YeP3FUoQEFvdDM9gqVq7sXH1cj2wtC7Y9\n9uK9\r\n=fHcK\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFhppyPpHO/oeTIB4UZMlyZ2jl1+BXcdmMeCjpg6Zl6nAiEA1+M0Xy4bhly+Iw+u7RY/FZl3oVwZx6sybfaK7H9yhlE="}]},"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"_npmUser":{"name":"lukeed","email":"luke@lukeed.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/scorta_0.0.0_1601853009378_0.5163828657830802"},"_hasShrinkwrap":false},"1.0.0":{"name":"scorta","version":"1.0.0","repository":{"type":"git","url":"git+https://github.com/lukeed/scorta.git"},"description":"A tiny (330B to 357B) and fast utility to find a package's hidden supply / cache 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"},"exports":{".":{"import":"./dist/index.mjs","require":"./dist/index.js"},"./sync":{"import":"./sync/index.mjs","require":"./sync/index.js"}},"modes":{"sync":"src/sync.js","default":"src/async.js"},"engines":{"node":">=6"},"scripts":{"build":"bundt","pretest":"npm run build","test":"uvu -r esm test -i fixtures"},"keywords":["find","cache","module","directory","storage","supply","tmpdir"],"dependencies":{"escalade":"^3.1.0"},"devDependencies":{"bundt":"1.1.1","esm":"3.2.25","uvu":"0.3.4"},"gitHead":"de45b44dbb548315e6b841f14c652f31beffc082","bugs":{"url":"https://github.com/lukeed/scorta/issues"},"homepage":"https://github.com/lukeed/scorta#readme","_id":"scorta@1.0.0","_npmVersion":"6.4.1","_nodeVersion":"10.13.0","_npmUser":{"name":"lukeed","email":"luke@lukeed.com"},"dist":{"integrity":"sha512-q6qyZNQEeJopoG5eWMVb92qeeKVRaThhaDwlyhu7V2MAROZjD0BJyGaNnf4d+QJcaJu+Mv72RqEB+BZVo+ONCA==","shasum":"fc99e241063bc521f24c4a18f2358e9d363ad466","tarball":"https://registry.npmjs.org/scorta/-/scorta-1.0.0.tgz","fileCount":9,"unpackedSize":11190,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfe2wpCRA9TVsSAnZWagAAxLEP/j9ghEN7KSvqlgrmznDP\n2/YSR6DuHSTaDzs7v+Tidery/lHgWa5MRik5j7bRrfMWfJWhOqftAdU50aLs\nggEa/hGtAwEva6XBBmSxhyRtL1bGsg1m9jS/daSrQX2cPlRiZtzaZZ1lTsQ3\nFfdUiHO/BleREbBKUZ0T8RhgqGqv0AMpXJbDxhnD8tETRVacpYpijyZqTVjW\njnsbsl1xO2j/oPx3QdqfnKYIwoEaZnWjujNDdAY4lju1AKGsYMk0xNb/MtjE\nQUku81wUMxPGf5VzrcYb7D8Npzh6UxXe4wvBtlJvH1/4YASv2hdfGP76pGGD\n9Rln0kCbqlpj5NfrLzMB317h1bvucErFXQgv/8oEAXWB5JKWTl5vJVNIbAfp\no07H3ot5zMEwxONaNpFjrCUX1omehnDaSc7msU5Li2k9O8nlTXii5HVYXg1k\nlYOEoHI+Rvv9kIjNxRpCKYTKkVmIS50fp8kHv7Zgr9mVHU85loC1OP4oZ+ef\n4XvAvvoNmSShNf1Kw+FxjDIDHMob/NBJyvynZbLvVVhKpBqQmL1wEe2fMRcX\n2Mg7DS6BV6gh4SqVioJHH3AkN+GHfaKAOv1bx5We2p+4v6VQBOBTxay1Etao\nbOPzwqnb4JF9mxT/kdpQZfuVe6JkAf2tZgEIbIFPletnQI5GjCJNU5ojjEn6\n0w79\r\n=8ryX\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDNazh3ULVZaMzcpeIeA4Kzu3rReC8JcIJIE4j0GXRrQwIgTuBJ1vdtbI8s8O9/QM7CweVAqONE6K1bm8+v0E02fEw="}]},"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/scorta_1.0.0_1601924136978_0.7653726006489203"},"_hasShrinkwrap":false}},"time":{"created":"2020-10-04T23:10:09.378Z","0.0.0":"2020-10-04T23:10:09.512Z","modified":"2022-05-17T06:09:32.088Z","1.0.0":"2020-10-05T18:55:37.119Z"},"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"description":"A tiny (330B to 357B) and fast utility to find a package's hidden supply / cache directory","homepage":"https://github.com/lukeed/scorta#readme","keywords":["find","cache","module","directory","storage","supply","tmpdir"],"repository":{"type":"git","url":"git+https://github.com/lukeed/scorta.git"},"author":{"name":"Luke Edwards","email":"luke.edwards05@gmail.com","url":"https://lukeed.com"},"bugs":{"url":"https://github.com/lukeed/scorta/issues"},"license":"MIT","readme":"# scorta [![CI](https://github.com/lukeed/scorta/workflows/CI/badge.svg)](https://github.com/lukeed/scorta/actions) [![codecov](https://badgen.now.sh/codecov/c/github/lukeed/scorta)](https://codecov.io/gh/lukeed/scorta)\n\n> A tiny (330B to 357B) and [fast](#benchmarks) utility to find a module's hidden supply / cache directory.\n\nWith `scorta`, you can locate a module's private `.cache` directory by name.\nThis is a common practice among many popular libraries, including AVA, `nyc`, Babel, etc.\n\n```sh\n# Others\n./node_modules/.cache/ava\n./node_modules/.cache/babel\n./node_modules/.cache/nyc\n# Yours!\n./node_modules/.cache/hello-world\n```\n\nWhen searching, the following steps are taken:\n\n1) Echo the value of `process.env.CACHE_DIR` if defined and truthy\n2) [Traverse parent directories](https://github.com/lukeed/escalade) until a `package.json` file is found\n3) If a `package.json` was found, return a `node_modules/.cache/{name}` path _only_ if it's not read-only\n4) All other cases return a `fallback`, which is either `undefined` or a [`os.tmpdir`](https://nodejs.org/api/os.html#os_os_tmpdir) value\n\n> **Why \"scorta\"?** It's Italian for a stock or a supply, which is generally the purpose for a `.cache` directory.\n\n\n## Install\n\n```\n$ npm install --save scorta\n```\n\n\n## Modes\n\nThere are two \"versions\" of `scorta` available:\n\n#### \"async\"\n> **Node.js:** >= 8.x<br>\n> **Size (gzip):** 357 bytes<br>\n> **Availability:** [CommonJS](https://unpkg.com/scorta/dist/index.js), [ES Module](https://unpkg.com/scorta/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):** 330 bytes<br>\n> **Availability:** [CommonJS](https://unpkg.com/scorta/sync/index.js), [ES Module](https://unpkg.com/scorta/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***Example Structure***\n\n```\n/example\n  ├── fixtures\n    └── empty.js\n  └── demo\n    └── node_modules/...\n    └── package.json\n    └── index.js\n```\n\n***Example Usage***\n\n```js\n// demo/index.js\n\nimport { join } from 'path';\nimport { scorta } from 'scorta';\n\nconst fixtures = join(__dirname, '..', 'fixtures');\n\nawait scorta('hello');\n//=> \"/example/demo/node_modules/.cache/hello\"\n\nawait scorta('hello', { cwd: fixtures });\n//=> undefined\n\nawait scorta('hello', { cwd: fixtures, tmpdir: true });\n//=> \"/var/folders/77/hdmgkj_x2l7454w0y5lwv2l80000gn/T\"\n```\n\n> **Note:** To run the above example with \"sync\" mode, import from `scorta/sync` & remove the `await`s.\n\n\n## API\n\n### scorta(name, options)\nReturns: `Promise<string|void>` or `string|void`\n\nWhen `scorta` locates a valid directory, the value will always be an absolute path (`string`).\n\nHowever, if `scorta` cannot locate a valid, writable directory, then the return value is `undefined` by default. However, this can be changed via the [`tmpdir`](#optionstmpdir) option.\n\n> **Important:**<br>The `sync` and `async` versions share the same API.<br>The **only** difference is that `sync` is not Promise-based.\n\n#### name\nType: `string`\n\nThe target module's name.\n\nThis value is used to construct the final `.cache` directory path. For example:\n\n```js\nawait scorta('hello');\n//=> /.../node_modules/.cache/hello\n```\n\n#### options.cwd\nType: `string`<br>\nDefault: `.`\n\nThe directory where path resolution should begin.\nDefauls to the `process.cwd()` – aka, the directory that your `process` is run within.\n\n\n#### options.tmpdir\nType: `boolean`<br>\nDefault: `false`\n\nWhen truthy, `scorta` will return a [`os.tmpdir()`](https://nodejs.org/api/os.html#os_os_tmpdir) value instead of `undefined`.\n\n> **Important:** When this option is in use, `scorta` always yields a string!\n\n\n## Benchmarks\n\n> Running on Node.js v10.13.0\n\n```\n# Load Time\n  find-cache-dir  11.628ms\n  scorta           1.326ms\n  scorta/sync      0.508ms\n\n# Levels: 0 (target = \"foo\"):\n  find-cache-dir   x 10,700 ops/sec ±0.55% (82 runs sampled)\n  scorta/sync      x 11,060 ops/sec ±0.83% (88 runs sampled)\n  scorta           x 80,804 ops/sec ±2.22% (74 runs sampled)\n\n# Levels: 6 (target = \"bar\"):\n  find-cache-dir   x  2,107 ops/sec ±0.42% (89 runs sampled)\n  scorta/sync      x  5,507 ops/sec ±0.46% (91 runs sampled)\n  scorta           x 78,593 ops/sec ±4.03% (79 runs sampled)\n\n# Levels: 11 (target = \"baz\"):\n  find-cache-dir   x  1,377 ops/sec ±0.36% (93 runs sampled)\n  scorta/sync      x  3,892 ops/sec ±0.25% (95 runs sampled)\n  scorta           x 76,641 ops/sec ±6.92% (68 runs sampled)\n```\n\n\n## Related\n\n- [escalade](https://github.com/lukeed/escalade) - A tiny (183B to 210B) utility to ascend parent directories\n- [totalist](https://github.com/lukeed/totalist) - A tiny (195B to 224B) utility to recursively list all (total) files in a directory\n- [mk-dirs](https://github.com/lukeed/mk-dirs) - A tiny (380B to 420B) utility to make a directory and its parents, recursively\n\n\n## License\n\nMIT © [Luke Edwards](https://lukeed.com)\n","readmeFilename":"readme.md"}