{"_id":"quick-lru-ts","_rev":"1-20479e2c26439305537ca10000d7bb20","name":"quick-lru-ts","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"quick-lru-ts","version":"1.0.0","description":"Simple “Least Recently Used” (LRU) cache","license":"MIT","repository":{"type":"git","url":"git+https://github.com/greguintow/quick-lru-ts.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"engines":{"node":">=12"},"scripts":{"build":"tsc -p tsconfig.json","prepublish:npm":"npm run build","publish:npm":"npm publish --access public","//test":"xo && nyc ava && tsd","test":"xo && ava && tsd"},"keywords":["lru","quick","cache","caching","least","recently","used","fast","map","hash","buffer","ts","typescript"],"devDependencies":{"ava":"^3.15.0","nyc":"^15.1.0","tsd":"^0.14.0","typescript":"^4.5.4","xo":"^0.37.1"},"nyc":{"reporter":["text","lcov"]},"gitHead":"e3a5dba5a4d28cbb77a2441828248d7e84ecc3d2","bugs":{"url":"https://github.com/greguintow/quick-lru-ts/issues"},"homepage":"https://github.com/greguintow/quick-lru-ts#readme","_id":"quick-lru-ts@1.0.0","_nodeVersion":"14.18.1","_npmVersion":"6.14.15","dist":{"integrity":"sha512-1jCBmnKRVmDQHQXsrxjXH4GEPLAIXj/mDZ6lRt9ckBDXEtMI4vgMA8XTI7MFhcOE835KlL+hQnOsEy7f1pt3pw==","shasum":"6f0a9d9bb81e0240b93df493d26e1f7726b8b1c7","tarball":"https://registry.npmjs.org/quick-lru-ts/-/quick-lru-ts-1.0.0.tgz","fileCount":6,"unpackedSize":245924,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh20JiCRA9TVsSAnZWagAA6bsP+gPwir134hJQo0wMRfFQ\nzt73BdPqKB/lRnP9efhogbjUG+JI1JPyxyDHrqV6cfguJwSnoi1mJ9uz7awY\nsH/Gg6maI7zZn5+gkmzdnQri8tOAi6AckFLqoSoO1ABVWXdtOO0P3WXjxQml\ngoN76p0qfs0wlfXVm3pM2q41AYwuwIFIvH/GXSrcJmo+IIf71j9Zgf3xrbbh\n77kVLEyoVlYlyQBa4pAdl2NNoekzaav82PqC4S53gokqHVdQxjETcsZSO35l\nNXiW4rVRH8mVTl5Kh0GWMXh9R6R8/uf3G3Idzf/f7o35K2QdqlemIUpVv7nj\ncalZzhiwEv/w3qg8G/Mw9KyzvyFdslUmbtX/eO9d8rBBu+FQZh0DV4gyDV9O\nPifUB21O6sPAM/J4W1ncc0ffKnW3bIKi8jhF0cVPuHESjpNb8jqY9Tt/FHiw\nx0TmYELmAZSwcYFkkRs+N5TuVzG5tiBviDfau+MWYzneiXMbyXuuP9EEQTHy\nJfyHjABJSOkw0eKl03wKM+FzrCuWNCEwuzJ1MPNu+dsMe9YUGifoZf+b3dEE\nh69UZyu+gxijM0snSqCZxGdp3OgjXRwEEqxzJyO73r5FVIC/CQqGtotsXrOT\ns0VA9CQPe1w7alk5GhM4Degcz1xzjYtvDwa2FkKeAvW6VpnHUoJpKG1KPeYv\nZYMO\r\n=w9nm\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCID7aECnxj/L5mASXpDZDQMBCzytbnieLpHKQG5XSJi72AiBZL3cYy5hZxEWUEnbb2XcU3RpYpZkRas6E7aGwK22NJA=="}]},"_npmUser":{"name":"greguintow","email":"thunderdance6@gmail.com"},"directories":{},"maintainers":[{"name":"greguintow","email":"thunderdance6@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/quick-lru-ts_1.0.0_1641759330088_0.8941514311348506"},"_hasShrinkwrap":false}},"time":{"created":"2022-01-09T20:15:30.000Z","1.0.0":"2022-01-09T20:15:30.241Z","modified":"2022-05-13T22:47:55.319Z"},"maintainers":[{"name":"greguintow","email":"thunderdance6@gmail.com"}],"description":"Simple “Least Recently Used” (LRU) cache","homepage":"https://github.com/greguintow/quick-lru-ts#readme","keywords":["lru","quick","cache","caching","least","recently","used","fast","map","hash","buffer","ts","typescript"],"repository":{"type":"git","url":"git+https://github.com/greguintow/quick-lru-ts.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"bugs":{"url":"https://github.com/greguintow/quick-lru-ts/issues"},"license":"MIT","readme":"# quick-lru-ts [![Coverage Status](https://codecov.io/gh/sindresorhus/quick-lru/branch/main/graph/badge.svg)](https://codecov.io/gh/sindresorhus/quick-lru/branch/main)\n\n>Note: This is just a conversion to TypeScript from the original [quick-lru](https://github.com/sindresorhus/quick-lru)\n\n\n> Simple [“Least Recently Used” (LRU) cache](https://en.m.wikipedia.org/wiki/Cache_replacement_policies#Least_Recently_Used_.28LRU.29)\n\nUseful when you need to cache something and limit memory usage.\n\nInspired by the [`hashlru` algorithm](https://github.com/dominictarr/hashlru#algorithm), but instead uses [`Map`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Map) to support keys of any type, not just strings, and values can be `undefined`.\n\n## Install\n\n```\n$ npm install quick-lru-ts\n```\n\n## Usage\n\n```js\nimport { QuickLRU } from 'quick-lru-ts';\n\nconst lru = new QuickLRU({maxSize: 1000});\n\nlru.set('🦄', '🌈');\n\nlru.has('🦄');\n//=> true\n\nlru.get('🦄');\n//=> '🌈'\n```\n\n## API\n\n### new QuickLRU(options?)\n\nReturns a new instance.\n\n### options\n\nType: `object`\n\n#### maxSize\n\n*Required*\\\nType: `number`\n\nThe maximum number of items before evicting the least recently used items.\n\n#### maxAge\n\nType: `number`\\\nDefault: `Infinity`\n\nThe maximum number of milliseconds an item should remain in cache.\nBy default maxAge will be Infinity, which means that items will never expire.\n\nLazy expiration happens upon the next `write` or `read` call.\n\nIndividual expiration of an item can be specified by the `set(key, value, options)` method.\n\n#### onEviction\n\n*Optional*\\\nType: `(key, value) => void`\n\nCalled right before an item is evicted from the cache.\n\nUseful for side effects or for items like object URLs that need explicit cleanup (`revokeObjectURL`).\n\n### Instance\n\nThe instance is an [`Iterable`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Iteration_protocols) of `[key, value]` pairs so you can use it directly in a [`for…of`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Statements/for...of) loop.\n\nBoth `key` and `value` can be of any type.\n\n#### .set(key, value, options?)\n\nSet an item. Returns the instance.\n\nIndividual expiration of an item can be specified with the `maxAge` option. If not specified, the global `maxAge` value will be used in case it is specified on the constructor, otherwise the item will never expire.\n\n#### .get(key)\n\nGet an item.\n\n#### .has(key)\n\nCheck if an item exists.\n\n#### .peek(key)\n\nGet an item without marking it as recently used.\n\n#### .delete(key)\n\nDelete an item.\n\nReturns `true` if the item is removed or `false` if the item doesn't exist.\n\n#### .clear()\n\nDelete all items.\n\n#### .resize(maxSize)\n\nUpdate the `maxSize`, discarding items as necessary. Insertion order is mostly preserved, though this is not a strong guarantee.\n\nUseful for on-the-fly tuning of cache sizes in live systems.\n\n#### .keys()\n\nIterable for all the keys.\n\n#### .values()\n\nIterable for all the values.\n\n#### .entriesAscending()\n\nIterable for all entries, starting with the oldest (ascending in recency).\n\n#### .entriesDescending()\n\nIterable for all entries, starting with the newest (descending in recency).\n\n#### .size\n\nThe stored item count.\n\n## Related\n\n- [yocto-queue](https://github.com/sindresorhus/yocto-queue) - Tiny queue data structure\n\n---\n\n<div align=\"center\">\n\t<b>\n\t\t<a href=\"https://tidelift.com/subscription/pkg/npm-quick-lru?utm_source=npm-quick-lru&utm_medium=referral&utm_campaign=readme\">Get professional support for this package with a Tidelift subscription</a>\n\t</b>\n\t<br>\n\t<sub>\n\t\tTidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.\n\t</sub>\n</div>\n","readmeFilename":"readme.md"}