{"name":"quick-lru","version":"6.1.1","description":"Simple “Least Recently Used” (LRU) cache","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/quick-lru.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":"./index.js","engines":{"node":">=12"},"scripts":{"//test":"xo && nyc ava && tsd","test":"xo && ava && tsd"},"keywords":["lru","quick","cache","caching","least","recently","used","fast","map","hash","buffer"],"devDependencies":{"ava":"^3.15.0","nyc":"^15.1.0","tsd":"^0.14.0","xo":"^0.37.1"},"nyc":{"reporter":["text","lcov"]},"types":"./index.d.ts","gitHead":"771392878fc0e2325b1172d04260e87afe94c8f7","bugs":{"url":"https://github.com/sindresorhus/quick-lru/issues"},"homepage":"https://github.com/sindresorhus/quick-lru#readme","_id":"quick-lru@6.1.1","_nodeVersion":"16.14.0","_npmVersion":"8.3.2","dist":{"integrity":"sha512-S27GBT+F0NTRiehtbrgaSE1idUAJ5bX8dPAQTdylEyNlrdcH5X4Lz7Edz3DYzecbsCluD5zO8ZNEe04z3D3u6Q==","shasum":"f8e5bf9010376c126c80c1a62827a526c0e60adf","tarball":"http://registry-npm.ywwl.com/quick-lru/download/quick-lru-6.1.1.tgz","fileCount":5,"unpackedSize":15226,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiPy7rACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmoojg//dT1oijG0PTgFFfjNFa+FgrOkaldeU1DD2xkWBZas2SwwKcQ4\r\nX7dsLXDunwf689oM5uliqcD12g9PRi5L/kJ/yqayh18UHUH3FriT1F7sSZb/\r\nQi8ByWW3wBMBFDRuT1vVmfxFq4zNG99T00CdAULJvclNdCxPxQeK2W2bQoJS\r\n8yshGW97YXesSKFYizFLDbRx5V50IQxBpfkUvcZIsb9XotHIos8o+GgdsEZh\r\nN55D9UsAbKzWMtHD8xxdXkBU/I8mIa4Kc982AELiE1A68kWbAhuBBtvYxk+J\r\n7J+gijdERqk1MdrmQ8J42SHlPulRmNKxglKV09Rbvdk17lJK5WLl0ZRVhjdc\r\noE0qmwVs5JCPKKfW9F8dT3buv2pnaOiW7kEBwETB1D4POJYxUwqmjhmgV2nT\r\n8ZUzf37M3VnnXGOBiaGuWBlUBGGlmo3uC+NS9a6ihOKcIZ5KbC053x6be2Lx\r\nzs6jbmNddysDPIZJpjok2KJAAh7/OoEg9uu++QTMcheYUN/0JqcF38B+LyS4\r\ndUkPNbeHFnenrKbZ4I0doigt052lH7R8Uzho0sDXGbSpHixXB2OW6wt8Fo1e\r\nL71xXtPwANKIVG9awiOFhe2MfdcnNjZfOUsoSZFIXTW2iy8C9UGVc1qLbx5W\r\n7G2HyF6kYGd28XVvjWLw4zBJ/rKw6ddBWPE=\r\n=9lL3\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEqND0ZDUsL95nVUJbQqLuELrX2LWAqpQM4lnYhCdNVtAiEAzLrR+0b7Emx0xvg1amSrY9AAMKZZCuCpU0TccAyOnkg="}],"size":4774,"noattachment":false,"key":"/quick-lru/-/quick-lru-6.1.1.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/quick-lru_6.1.1_1648307946784_0.9757007166465537"},"_hasShrinkwrap":false,"readme":"# quick-lru [![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> 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```sh\nnpm install quick-lru\n```\n\n## Usage\n\n```js\nimport QuickLRU from 'quick-lru';\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\nIt's a [`Map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) subclass.\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#### .entries()\n\nIterable for all entries, starting with the newest (ascending in recency).\n\n**This method exists for `Map` compatibility. Prefer [.entriesAscending()](#entriesascending) instead.**\n\n#### .forEach(callbackFunction, thisArgument)\n\nLoop over entries calling the `callbackFunction` for each entry (ascending in recency).\n\n**This method exists for `Map` compatibility. Prefer [.entriesAscending()](#entriesascending) instead.**\n\n#### .size *(getter)*\n\nThe stored item count.\n\n#### .maxSize *(getter)*\n\nThe set max size.\n\n## Related\n\n- [yocto-queue](https://github.com/sindresorhus/yocto-queue) - Tiny queue data structure\n","publish_time":1648307947150,"_cnpm_publish_time":1648307947150,"dist-tags":{"latest":"7.3.0"}}