{"_id":"@7hci/file-system-cache","_rev":"2-bb5b918f745ade00cc3e2fb4e047ac6a","name":"@7hci/file-system-cache","dist-tags":{"latest":"3.2.0"},"versions":{"3.1.0":{"name":"@7hci/file-system-cache","version":"3.1.0","keywords":["cache","fs","file-system"],"author":{"url":"https://github.com/philcockfield","name":"Phil Cockfield","email":"phil@cockfield.net"},"license":"MIT","_id":"@7hci/file-system-cache@3.1.0","maintainers":[{"name":"ssayles","email":"scott@7hci.com"}],"homepage":"https://github.com/philcockfield/file-system-cache","dist":{"shasum":"051a269666a18440ce1142350ee288ea8a4f53f1","tarball":"https://registry.npmjs.org/@7hci/file-system-cache/-/file-system-cache-3.1.0.tgz","fileCount":8,"integrity":"sha512-OiFHQJbYxKRenmj5FeoVSEFaADeBiSjHq/ZxGRmPkxtQxY6Nr+WFAk+rVXIr/r/pYqKdDettOHT5hS8FwR5VFA==","signatures":[{"sig":"MEUCIDllRMX2m2cJSn6WMqPHGwGBHM+Mdi2Ymc/2xO01qJHiAiEAqZDkFIzrcTHUFAZEcTC5WqzetGdwYaQFduEYjLctEM8=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":104917},"main":"./lib/index.js","type":"module","exports":{".":{"types":"./lib/index.d.ts","import":"./lib/index.js"},"./package.json":"./package.json"},"scripts":{"test":"vitest","build":"tsup src/index.ts --clean --minify --dts --format esm --out-dir lib --treeshake","format":"prettier ./src --write","prepublish":"npm test && npm run build","gen:hashtype":"tsx ./script.ts/generate-hashtype.ts"},"_npmUser":{"name":"ssayles","email":"scott@7hci.com"},"repository":{"url":"https://github.com/philcockfield/file-system-cache","type":"git"},"description":"A super-fast, promise-based cache that reads and writes to the file-system. This is a fork of the original file-system-cache package.","directories":{},"licenseText":"The MIT License (MIT)\n\nCopyright (c) 2015 Phil Cockfield <phil@cockfield.net> (https://github.com/philcockfield)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n","resolutions":{"vite":">=5.3.3","braces":">=3.0.3"},"_hasShrinkwrap":false,"packageManager":"yarn@1.22.19+sha512.ff4579ab459bb25aa7c0ff75b62acebe576f6084b36aa842971cf250a5d8c6cd3bc9420b22ce63c7f93a0857bc6ef29291db39c3e7a23aab5adfd5a4dd6c5d71","devDependencies":{"tsx":"^4.16.2","chai":"^5.1.1","tsup":"^8.1.0","ramda":"^0.30.1","vitest":"^2.0.3","fs-extra":"^11.2.0","prettier":"^3.3.3","typescript":"^5.5.3","@types/chai":"^4.3.16","@types/ramda":"^0.30.1","@types/expect":"^24.3.0","@types/fs-extra":"^11.0.4"},"_npmOperationalInternal":{"tmp":"tmp/file-system-cache_3.1.0_1743436655101_0.2439550880055288","host":"s3://npm-registry-packages-npm-production"}},"3.2.0":{"name":"@7hci/file-system-cache","version":"3.2.0","description":"A super-fast, promise-based cache that reads and writes to the file-system. This is a fork of the original file-system-cache package.","keywords":["cache","fs","file-system"],"homepage":"https://github.com/philcockfield/file-system-cache","repository":{"type":"git","url":"https://github.com/philcockfield/file-system-cache"},"license":"MIT","author":{"name":"Phil Cockfield","email":"phil@cockfield.net","url":"https://github.com/philcockfield"},"type":"module","exports":{".":{"types":"./lib/index.d.ts","import":"./lib/index.js"},"./package.json":"./package.json"},"main":"./lib/index.js","scripts":{"build":"tsc","format":"prettier ./src --write","gen:hashtype":"tsx ./script.ts/generate-hashtype.ts","prepublish":"npm test && npm run build","test":"vitest"},"devDependencies":{"@types/chai":"^4.3.16","@types/expect":"^24.3.0","@types/fs-extra":"^11.0.4","@types/ramda":"^0.30.1","chai":"^5.1.1","fs-extra":"^11.2.0","prettier":"^3.3.3","ramda":"^0.30.1","tsup":"^8.1.0","tsx":"^4.16.2","typescript":"^5.5.3","vitest":"^2.0.3"},"resolutions":{"braces":">=3.0.3","vite":">=5.3.3"},"packageManager":"yarn@1.22.19+sha512.ff4579ab459bb25aa7c0ff75b62acebe576f6084b36aa842971cf250a5d8c6cd3bc9420b22ce63c7f93a0857bc6ef29291db39c3e7a23aab5adfd5a4dd6c5d71","licenseText":"The MIT License (MIT)\n\nCopyright (c) 2015 Phil Cockfield <phil@cockfield.net> (https://github.com/philcockfield)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n","_id":"@7hci/file-system-cache@3.2.0","dist":{"shasum":"f96576444b7d0f64efcc3c93782d3ba31ab87a69","integrity":"sha512-H6JFsksdjQ62kai8x7fZAUFkWENqaJHqs/BlmiRHXyIBgLBzj1QyihjbzF8myJawaaNPRTdcxKsQNxbxhoUUzw==","tarball":"https://registry.npmjs.org/@7hci/file-system-cache/-/file-system-cache-3.2.0.tgz","fileCount":25,"unpackedSize":20870,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCkVKuG2OsJ1UJm/mi1JqGMvZpuRYawNQFg0Dvz/sEapwIgdKHAqHBtScB1VTwxHHt6Yj8joMPUtgr5j8f40NMRzb0="}]},"_npmUser":{"name":"ssayles","email":"scott@7hci.com"},"directories":{},"maintainers":[{"name":"ssayles","email":"scott@7hci.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/file-system-cache_3.2.0_1743437682092_0.8528470471501415"},"_hasShrinkwrap":false}},"time":{"created":"2025-03-31T15:57:35.040Z","modified":"2025-03-31T16:14:42.492Z","3.1.0":"2025-03-31T15:57:35.267Z","3.2.0":"2025-03-31T16:14:42.292Z"},"author":{"name":"Phil Cockfield","email":"phil@cockfield.net","url":"https://github.com/philcockfield"},"license":"MIT","homepage":"https://github.com/philcockfield/file-system-cache","keywords":["cache","fs","file-system"],"repository":{"type":"git","url":"https://github.com/philcockfield/file-system-cache"},"description":"A super-fast, promise-based cache that reads and writes to the file-system. This is a fork of the original file-system-cache package.","maintainers":[{"name":"ssayles","email":"scott@7hci.com"}],"readme":"[![ci(esm)](https://github.com/philcockfield/file-system-cache/actions/workflows/node.esm.yml/badge.svg)](https://github.com/philcockfield/file-system-cache/actions/workflows/node.esm.yml)\n\n> **Note**\n> This fork as support for customizable hash and json formatting.\n\n# file-system-cache\n\nA super-fast, promise-based cache that reads and writes to the file-system.\n\n\n## Installation\n\n    npm install --save file-system-cache\n\nImport\n\n```ts\nimport Cache from 'file-system-cache';\n\n   // or ↑↓ (equivalent)\n\nimport { Cache } from 'file-system-cache';\n```\n\n## Usage (API)\n\nCreate an instance of the cache optionally giving it a folder location to store files within.\n\n```js\nimport Cache from \"file-system-cache\";\n\nconst cache = Cache({\n  basePath: \"./.cache\", // (optional) Path where cache files are stored (default).\n  ns: \"my-namespace\",   // (optional) A grouping namespace for items.\n  hash: \"sha1\",         // (optional) A hashing algorithm used within the cache key.\n  ttl: 60,              // (optional) A time-to-live (in secs) on how long an item remains cached.\n});\n```\n\n> Reference `default` for CommonJS, e.g: `const Cache = require('file-system-cache').default\n`\n\nThe optional `ns` (\"namespace\") allows for multiple groupings of files to reside within the one cache folder.  When you have multiple caches with different namespaces you can re-use the same keys and they will not collide.\n\nThe optional `ttl` (\"time to live\") allows you to set a default expiration for the cache key, in seconds. For example if you\nset this value to 60 then cache hits to any cache key made beyond the limit of that 60 seconds will result in cache misses.\n\n### get(key, defaultValue)\nRetrieves the contents of a cached file.\n\n```js\ncache.get(\"foo\")\n  .then(result => /* Success */)\n  .catch(err => /* Fail */);\n```\n\nor use modern `async/await` syntactic sugar of course:\n\n```js\nconst value = await cache.get(\"foo\");\n```\n\nUse `getSync` for a synchronous version.  \nPass a `defaultValue` parameter to use if the key does not exist within the cache.\n\n\n### set(key, value, ttl)\nWrite a value to the cache.\n\n```js\n/* This will apply the default TTL to this cache key */\ncache.set(\"foo\", \"...value...\")\n  .then(result => /* Success */)\n\n/* This will set a specific TTL for this cache key */\ncache.set(\"bar\", \"...baz\", 60)\n  .then(result => /* Success */)\n```\n\nValue types are stored and respected on subsequent calls to `get`.  For examples, passing in Object will return that in its parsed object state.\n\nUse `setSync` for a synchronous version.\n\n### remove(key)\nDeletes the specified cache item from the file-system.\n```js\ncache.remove(\"foo\")\n  .then(() => /* Removed */)\n```\n\n### clear()\nClears all cached items from the file-system.\n```js\ncache.clear()\n  .then(() => /* All items deleted */)\n```\n\n\n### save()\nSaves (sets) several items to the cache in one operation.\n```js\ncache.save([{ key:\"one\", value:\"hello\" }, { key:\"two\", value:222 }])\n  .then(result => /* All items saved. */)\n```\n\n### load()\nLoads all files within the cache's namespace.\n```js\ncache.load()\n  .then(result => /* The complete of cached files (for the ns). */)\n```\n\n\n\n## Test\n    # Run tests.\n    npm test\n\n","readmeFilename":"README.md"}