{"_id":"@cjser/quick-lru__v6_1_2","name":"@cjser/quick-lru__v6_1_2","dist-tags":{"latest":"6.1.2-cjser.2"},"versions":{"6.1.2-cjser.2":{"name":"@cjser/quick-lru__v6_1_2","version":"6.1.2-cjser.2","description":"Simple “Least Recently Used” (LRU) cache","license":"MIT","repository":{"type":"git","url":"https://code.moenext.com/3rdeye/cjser.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"require":"./dist-cjser/index.cjs","default":"./index.js"},"engines":{"node":">=12"},"scripts":{"//test":"xo && nyc ava && tsd","test":"xo && ava"},"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"]},"main":"./dist-cjser/index.cjs","cjser":{"sourceVersion":"6.1.2","cjserVersion":2,"original":{"name":"quick-lru","version":"6.1.2","exports":"./index.js","repository":"sindresorhus/quick-lru","files":["index.js","index.d.ts"],"scripts":{"//test":"xo && nyc ava && tsd","test":"xo && ava"}}},"_id":"@cjser/quick-lru__v6_1_2@6.1.2-cjser.2","gitHead":"a4bef54d7d22d3d9a6b84528457938d84cd65fe7","_nodeVersion":"20.14.0","_npmVersion":"10.7.0","dist":{"integrity":"sha512-48LDz2JKOXHM8UJP5Dk9kmtpYebB4XyF38x1r6el9E/x+heWfapoz570hjPRl/89WZu4ilUYfKFCjZeFNtRmxQ==","shasum":"3815eaad382583436210db9a30c1d9dddf396a73","tarball":"https://registry.npmjs.org/@cjser/quick-lru__v6_1_2/-/quick-lru__v6_1_2-6.1.2-cjser.2.tgz","fileCount":6,"unpackedSize":23542,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCBV+JhvalTx6LxcAeEVD2Ny8B5jak37UN6mZPwIpA37QIhAOMgFA4ILvgj8HQ6CfDZVlFBZMR9cKef7DD8+iwvLRyY"}]},"_npmUser":{"name":"nanahira","email":"nanahira@momobako.com"},"directories":{},"maintainers":[{"name":"nanahira","email":"nanahira@momobako.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/quick-lru__v6_1_2_6.1.2-cjser.2_1778159708642_0.6781297847830801"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-07T13:15:08.542Z","6.1.2-cjser.2":"2026-05-07T13:15:08.780Z","modified":"2026-05-07T13:15:09.008Z"},"maintainers":[{"name":"nanahira","email":"nanahira@momobako.com"}],"description":"Simple “Least Recently Used” (LRU) cache","keywords":["lru","quick","cache","caching","least","recently","used","fast","map","hash","buffer"],"repository":{"type":"git","url":"https://code.moenext.com/3rdeye/cjser.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"license":"MIT","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```\n$ npm 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\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\n## cjser\n\nThis package is a CommonJS-compatible build generated by cjser for projects that still need `require()` support. The source version matches the original npm package version, with a cjser prerelease suffix for this generated build.\nOriginal repository: https://github.com/sindresorhus/quick-lru\n","readmeFilename":"readme.md","_rev":"1-44cd9a7ebcc85f32f94661c2f2b4c7f2"}