{"_id":"tmp-cache","_rev":"6-0bdcd7de0cc13ff58cf0eefc7043a5c1","name":"tmp-cache","dist-tags":{"latest":"1.1.0"},"versions":{"0.0.0":{"name":"tmp-cache","version":"0.0.0","description":"> A tiny (135B) utility for safely writing deep Object values~!","_id":"tmp-cache@0.0.0","scripts":{},"_shasum":"aa5d8eae8d2937e692cc639dedcb0272a242a6c6","_from":".","_npmVersion":"3.10.10","_nodeVersion":"6.11.1","_npmUser":{"name":"lukeed","email":"luke@lukeed.com"},"dist":{"shasum":"aa5d8eae8d2937e692cc639dedcb0272a242a6c6","tarball":"https://registry.npmjs.org/tmp-cache/-/tmp-cache-0.0.0.tgz","fileCount":11,"unpackedSize":5651,"integrity":"sha512-2v/quxxMvB5vnHi5fvLxiLCOnZDI26s0jadPl0+1B5TF0vS/Yd/FiOtgloMR/3KZiSAVJh+OqliuWxGu2ruXSQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCMOynnklc8nzfGhm0rcL6woT5yHxwzUD2tABvp7hHHoQIhAJfWekrbZ10CrzJn5tjgXe5qRNcmu6/yXHrZ21ZQ0Zrw"}]},"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/tmp-cache_0.0.0_1523572375840_0.6033023838243845"},"_hasShrinkwrap":false},"1.0.0":{"name":"tmp-cache","version":"1.0.0","repository":{"type":"git","url":"git+https://github.com/lukeed/tmp-cache.git"},"description":"A least-recently-used cache manager in 35 lines of code","main":"lib/index.js","license":"MIT","author":{"name":"Luke Edwards","email":"luke.edwards05@gmail.com","url":"lukeed.com"},"engines":{"node":">=6"},"scripts":{"test":"tape test/*.js | tap-spec"},"files":["lib"],"keywords":["cache","lru","lru-cache","mru"],"devDependencies":{"tap-spec":"^4.1.1","tape":"^4.8.0"},"gitHead":"e89b841a73065fc3e8ac8e13c2f87f0c1a1e1b03","bugs":{"url":"https://github.com/lukeed/tmp-cache/issues"},"homepage":"https://github.com/lukeed/tmp-cache#readme","_id":"tmp-cache@1.0.0","_npmVersion":"5.5.1","_nodeVersion":"8.9.0","_npmUser":{"name":"lukeed","email":"luke@lukeed.com"},"dist":{"integrity":"sha512-yhGIuloMqunxSJwBnGJxuLNAW5mm1wnuYw3+N8PLKdqTuGhj7rDqWhN8smY9emElk4GI4T3Q5Vv8AMMkDmoL7Q==","shasum":"1538e96a0359885868d7889a4c75853ec7eea6df","tarball":"https://registry.npmjs.org/tmp-cache/-/tmp-cache-1.0.0.tgz","fileCount":4,"unpackedSize":6938,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJa0rQkCRA9TVsSAnZWagAA/TgQAKD4lgQ3HjhG8oV1UP7D\nNj8C1aLQ/tZRGv3cLgX4HfTP+5gBOXzUSvagouZSL3WjOAgBALnsftNOuuQV\nOpZU9jn9n3Suh43OMHQBCnAmcY8KGxXC6rpncZC/h5z8Qf/YRoAH56IladRP\ntESNQ7KVXaq09DRPAo2ruE6suU9mA9ylm/4NF6PkZRdWCMtVFVk5G9OTf/Yc\n6RELR6rDdepfaauwuxgD4LwuO87qwjg8gtKM8v9jPyxiW7uzl0ZJzaSCok8H\nK2B3uADm4UwS/lcXldH4flgQjZ0qdN+1E4UFwS+sk7JkQ4OEMLA5B0D68eG9\nUr0wWYnUnx2/4o2YNA7//7dAtl/gxD1/6aLAWhIdI3g5WxHSSNOKL4bJ5MSx\nhkweI6XNU1Pfwc6Qg8YB3sAnMLUSiz+rMZ7fPeZEkeOCg6uE0BuS8Dk1dtn3\neXBIdpLyn8KI6X6jXJ78MaRmusP8otwaMpU96nsPwO/ICpIdivnOBQGAihpT\n4nEM8sxtgmHSGm0fYx5IRDLU7xOqcbZflVMhul7dRYvM2wnzUsEmDf0/jvlK\nJOjEyDWrZz709h5zoKFVMoQ9ZI8NNbqU7yPc/4hePPTXxg7GHTndJq8J+z7U\nkqSoZsD+L3fRU4Y8JJPRNydd7mrZRjCSHXa6ZuqIn3F7gPdl52x5DhIWEjcz\nAD/C\r\n=2fSM\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIADjn6LOYpl9mDRKz3n8I7pJnaH1U0XCLUUnpPnMf6o6AiAcgYmHc1WTvp5fN2OBbaP5g6bHPLH+sorzoDs01juuWA=="}]},"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/tmp-cache_1.0.0_1523758115289_0.0782262156163902"},"_hasShrinkwrap":false},"1.1.0":{"name":"tmp-cache","version":"1.1.0","repository":{"type":"git","url":"git+https://github.com/lukeed/tmp-cache.git"},"description":"A least-recently-used cache in 35 lines of code","main":"lib/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":{"test":"uvu test"},"keywords":["cache","lru","lru-cache","mru"],"devDependencies":{"uvu":"0.3.3"},"gitHead":"15d18750678b2319b00b1fa8c285d46fbece7355","bugs":{"url":"https://github.com/lukeed/tmp-cache/issues"},"homepage":"https://github.com/lukeed/tmp-cache#readme","_id":"tmp-cache@1.1.0","_npmVersion":"6.4.1","_nodeVersion":"10.13.0","_npmUser":{"name":"lukeed","email":"luke@lukeed.com"},"dist":{"integrity":"sha512-j040fkL/x+XAZQ9K3bKGEPwgYhOZNBQLa3NXEADUiuno9C+3N2JJA4bVPDREixp604G3/vTXWA3DIPpA9lu1RQ==","shasum":"28b551cacdafee194540a47b47518b3fadaa049e","tarball":"https://registry.npmjs.org/tmp-cache/-/tmp-cache-1.1.0.tgz","fileCount":5,"unpackedSize":7256,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfV7U2CRA9TVsSAnZWagAA0nsP/inoCwGWJnl5a/qK+yBR\nNKaA6r5ojNcJsHonMEqTZOIZl4CheNuf27be7J5nqEydEdKxkW510plww4Ub\nhDR+0sFZ0D4XvRK2MlZYqZc/3MaOE167kEwsl1FZuojHw2GWLWiqhIKMGw1Z\ne74IPAAd3eGQqUDjLswb2vYBMzJJKXacN/p4IVlKYiWcrnrvwdZMMC9rA5Bi\nrDc7ljhsHzd2lApfA9aUTlMZtIvQKa++NnV9x17BKNBxfOb4AqQflfob3chD\n1h8S4yS/dnkGDmIwRcIVTo5hU4uXlMCLl8DlWMzxwtsMWt2t9QeCQJj7VYBE\nfWMiMhamnWWf4INUnfaMRrYltFZos0RD1ZT1ovJIpdohNgmGhoq1DbEsjMJh\nmp+pzNwRwQnzfrFI83orcYiCO75bb6wuIXh2+msOM/ak8ue5VPCwDy/VWDFe\nZXI0PJ5CC3Vrbu8POhhRCeWnEJ5VsBhl8fuuqu+xBDHydaWQP8dsSOvQB0ON\nV4KW64DcDfoMtBGiVetDASaU6tEbp75evZRrqPRmzESkp11GkVgl/J+hTZBo\nIFB3Aaqqqx4z+nHkeJdGFObbYZv4aJzxIOCsmkX1TbkzDXwlhDqAh5dXLDkD\nZM3ymI/PmnNRkSgj214IfRH5h1DZF8VXHeVu8fDeIpie8bnFLDzL+/wppr0q\n55eE\r\n=/IYX\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD+sVmpsOnP+93srnQApeWfDPhFzVijpjho4Old72xdvwIhANyiYleFU9OyQli6oWVedEHwyYtxQtMJRMfuSBJBbMpk"}]},"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/tmp-cache_1.1.0_1599583541670_0.9443659551991843"},"_hasShrinkwrap":false}},"time":{"created":"2018-04-12T22:32:55.840Z","0.0.0":"2018-04-12T22:32:55.966Z","modified":"2022-06-27T07:17:11.660Z","1.0.0":"2018-04-15T02:08:35.353Z","1.1.0":"2020-09-08T16:45:41.790Z"},"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"description":"A least-recently-used cache in 35 lines of code","readme":"# tmp-cache ![CI](https://github.com/lukeed/tmp-cache/workflows/CI/badge.svg) [![codecov](https://badgen.net/codecov/c/github/lukeed/tmp-cache)](https://codecov.io/gh/lukeed/tmp-cache)\n\n> A least-recently-used cache in 35 lines of code~!\n\nLRU caches operate on a first-in-first-out queue. This means that the first item is the oldest and will therefore be deleted once the `max` limit has been reached.\n\nWhen a `maxAge` value is set, items are given an expiration date. This allows existing items to become stale over time which, depending on your `stale` config, is equivalent to the item not existing at all!\n\nIn order to counteract this idle decay, all `set()` and `get()` operations on an item \"refresh\" its expiration date. By doing so, a new `expires` value is issued & the item is moved to the end of the list &mdash; aka, it's the newest kid on the block!\n\n\n## Install\n\n```\n$ npm install --save tmp-cache\n```\n\n\n## Usage\n\n```js\nconst Cache = require('tmp-cache');\n\nlet cache = new Cache(3); // sets \"max\" size\n\ncache.set('a', 1); //~> ['a']\ncache.set('b', 2); //~> ['a', 'b']\ncache.set('c', 3); //~> ['a', 'b', 'c']\ncache.get('a');    //~> ['b', 'c', 'a']\ncache.set('d', 4); //~> ['c', 'a', 'd']\ncache.peek('a');   //~> ['c', 'a', 'd']\ncache.delete('d'); //~> ['c', 'a']\ncache.has('d');    //=> false\ncache.set('e', 5); //~> ['c', 'a', 'e']\ncache.size;        //=> 3\ncache.clear();     //~> []\n\ncache = new Cache({ maxAge:10 });\n\ncache.set(123, 'hello'); //~> valid for 10ms\ncache.get(123); //=> 'hello'  --  resets 10ms counter\nsetTimeout(_ => cache.get(123), 25); //=> undefined\n\ncache = new Cache({ maxAge:0, stale:true });\n\ncache.set('foo', [123]); //~> already stale, 0ms lifespan\ncache.get('foo'); //=> [123]  --  because options.stale\ncache.get('foo'); //=> undefined  --  previous op flagged removal\n```\n\n## API\n\nAside from the items & changes mentioned below, `tmp-cache` extends the `Map` class, so all [properties and methods](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Map_instances) are inherited.\n\n### Cache(options)\n\nReturns: `Cache extends Map`\n\n#### options.max\n\nType: `Number`<br>\nDefault: `Infinity`\n\nThe maximum number of items the cache will hold. Adding more entries will force the oldest, least-recently-used item to be purged.\n\nFailure to include any `max` restriction could potentially allow infinite unique entries! They will only be purged based on their `expires` value (if set).\n\n> **Note:** If `options` is an integer, then it is used as the `options.max` value.\n\n#### options.maxAge\n\nType: `Number`<br>\nDefault: `-1`\n\nThe maximum age (in ms) an item is considered valid; aka, its lifespan.\n\nItems are not pro-actively pruned out as they age, but if you try to access an item that has expired, it will be purged and, by default, result in an `undefined` response.\n\n#### options.stale\n\nType: `Boolean`<br>\nDefault: `false`\n\nAllow an expired/stale item's value to be returned before deleting it.\n\n\n### Cache.set(key, value, maxAge?)\n\nPersists the item and its value into the Cache. If a `maxAge` value exists (via custom or cache-level options), an expiration date will also be stored.\n\nWhen setting or updating an item that already exists, the original is removed. This allows the new item to be unique & the most recently used!\n\n#### key\nType: `String`\n\nThe item's unique identifier.\n\n#### value\nType: `Mixed`\n\nThe item's value to cache.\n\n#### maxAge\nType: `Number`<br>\nDefault: `options.maxAge`\n\nOptionally override the [`options.maxAge`](#optionsmaxage) for this (single) operation.\n\n\n### Cache.get(key, mutate?)\n\nRetrieve an item's value by its key name. By default, this operation will refresh/update the item's expiration date.\n\nMay also return `undefined` if the item does not exist, or if it has expired & [`stale`](#optionsstale) is not set.\n\n#### key\nType: `String`\n\nThe item's unique identifier.\n\n#### mutate\nType: `Boolean`<br>\nDefault: `true`\n\nRefresh the item's expiration date, marking it as _more_ recently used.\n\n\n### Cache.peek(key)\n\nReturn an item's value without updating its position or refreshing its expiration date.\n\nMay also return `undefined` if the item does not exist, or if it has expired & [`stale`](#optionsstale) is not set.\n\n#### key\nType: `String`\n\nThe item's unique identifier.\n\n\n\n## License\n\nMIT © [Luke Edwards](https://lukeed.com)\n","readmeFilename":"readme.md","homepage":"https://github.com/lukeed/tmp-cache#readme","keywords":["cache","lru","lru-cache","mru"],"repository":{"type":"git","url":"git+https://github.com/lukeed/tmp-cache.git"},"author":{"name":"Luke Edwards","email":"luke.edwards05@gmail.com","url":"https://lukeed.com"},"bugs":{"url":"https://github.com/lukeed/tmp-cache/issues"},"license":"MIT"}