{"name":"quick-lru","version":"4.0.1","description":"Simple \"Least Recently Used\" (LRU) cache","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/quick-lru.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=8"},"scripts":{"test":"xo && nyc ava && tsd"},"keywords":["lru","quick","cache","caching","least","recently","used","fast","map","hash","buffer"],"devDependencies":{"ava":"^1.4.1","coveralls":"^3.0.3","nyc":"^14.1.1","tsd":"^0.7.2","xo":"^0.24.0"},"gitHead":"64c21e6e8898d2f2751357c422ae53c63ac66aff","bugs":{"url":"https://github.com/sindresorhus/quick-lru/issues"},"homepage":"https://github.com/sindresorhus/quick-lru#readme","_id":"quick-lru@4.0.1","_nodeVersion":"8.16.0","_npmVersion":"6.9.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"integrity":"sha512-ARhCpm70fzdcvNQfPoy49IaanKkTlRWF2JMzqhcJbhSFRZv7nPTvZJdcY7301IPmvW+/p0RgIWnQDLJxifsQ7g==","shasum":"5b8878f113a58217848c6482026c73e1ba57727f","tarball":"http://registry-npm.ywwl.com/quick-lru/download/quick-lru-4.0.1.tgz","fileCount":5,"unpackedSize":7469,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJc7r+bCRA9TVsSAnZWagAAQx4P/2Nu8oQyT6aWSMNbQXQs\nU8IThgCSLVFHOX3tIqlVhlLc8Zr4+jtY/xXjXSdlAHtPpRzTJNCsZMNU5T8V\n1YS5EMLs+zJbiJLdcbZ+yBI/3eNKxcT5bsWkAS1yLPgsrx6O0ypv4+vxKgV4\nvcST7nniuqi2mhE5aR/g3XP1+vJOR5b8uu4BCQGlL1wrO0oZHSXNfeY5uNsD\n/Tzyr8e+nWPJbo50fTMEm1xbGju4vqf4sgMhSYkIxymfWRuTPdxmnNH/JWU0\nYMH97BXghmhJ5ej3kTev3YkQSnVnAdz7c8bNhE+erbclez/WP65QAQyRLmvR\nJEMlvNd0O6ZOlb2aehzdsjl8nqsH+bL2N//g0ZFPEFGGUe4L+G+rIrv7O6U9\nLo+GpXi0gI/FECODJzsq/05otrIG0lbkVIZY1OH3DM8gQMlnGn1/hf8Hm9Ms\nj863/ckwYYrOza0BZB/hVAz9bMyQV5TMQ6mXINOCFVD+mzBVD3VEA7m58SmG\nFA5hjJ3Zb46nypJtihcqSqyGkSaoQYdXrVjMg01ocavM7dOefnJN2KbGUlwD\nT/rVI9N/ZU+fILQIwi1MxpiY7Eyryr6y6zPvBfbzb4jsYfAkaX8XxBwLEKP6\nl1FDTzMQMxnMzomtF6YxlSUgohoioaV9xWSa0pElsEMBcijlI3SqZfu2NTQq\nTFDL\r\n=Sy0n\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDow97hIbBBcQZqBqEWiPJaxL7Jfb3DerA17k7b412eEAiAXSPKHMRh0ZNJwa/ALZRD/DxRQ+kzPCvRPte0uoEzJ4g=="}],"size":2925,"noattachment":false,"key":"/quick-lru/-/quick-lru-4.0.1.tgz"},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/quick-lru_4.0.1_1559150490405_0.9876888152612853"},"_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":1559150490565,"_cnpm_publish_time":1559150490565,"dist-tags":{"latest":"7.3.0"}}