{"name":"ylru","version":"1.4.0","author":{"name":"fengmk2"},"license":"MIT","_id":"ylru@1.4.0","homepage":"https://github.com/node-modules/ylru","bugs":{"url":"https://github.com/node-modules/ylru/issues"},"ci":{"os":{"github":"linux"},"type":"github","version":"8, 10, 12, 14, 16","npminstall":false},"dist":{"shasum":"0cf0aa57e9c24f8a2cbde0cc1ca2c9592ac4e0f6","tarball":"http://registry-npm.ywwl.com/ylru/download/ylru-1.4.0.tgz","fileCount":5,"integrity":"sha512-2OQsPNEmBCvXuFlIni/a+Rn+R2pHW9INm0BxXJ4hVDA8TirqMj+J/Rp9ItLatT/5pZqWwefVrTQcHpixsxnVlA==","signatures":[{"sig":"MEUCICIEBMipsrJYfylsIADjbBQpjb+xyC/+ucAsa9kBf/NlAiEAgzwzGJwCUVlpvFyc647uqJS3ri+Ahk2ZnnREaPGtw74=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":9007,"size":3379,"noattachment":false,"key":"/ylru/-/ylru-1.4.0.tgz"},"main":"index.js","types":"./index.d.ts","engines":{"node":">= 4.0.0"},"gitHead":"3a030e7e4055b1b15bcea16a86cee5fe7b56651a","scripts":{"ci":"npm run lint && npm run cov","cov":"egg-bin cov","lint":"eslint test *.js","test":"npm run lint -- --fix && npm run test-local","test-local":"egg-bin test","contributor":"git-contributor"},"_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"repository":{"url":"git://github.com/node-modules/ylru.git","type":"git"},"_npmVersion":"10.2.4","description":"Extends LRU base on hashlru","directories":{},"_nodeVersion":"18.19.1","dependencies":{},"_hasShrinkwrap":false,"devDependencies":{"egg-ci":"^1.19.0","eslint":"^4.19.1","egg-bin":"^1.10.0","hashlru":"^1.0.3","ko-sleep":"^1.0.2","benchmark":"^2.1.3","lru-cache":"^4.0.2","runscript":"^1.5.2","typescript":"^4.6.2","@types/node":"^12.0.8","git-contributor":"^1.0.10","eslint-config-egg":"^6.0.0","beautify-benchmark":"^0.2.4"},"_npmOperationalInternal":{"tmp":"tmp/ylru_1.4.0_1711597475358_0.3637478527216105","host":"s3://npm-registry-packages"},"readme":"# ylru\n\n[![NPM version][npm-image]][npm-url]\n[![Node.js CI](https://github.com/node-modules/ylru/actions/workflows/nodejs.yml/badge.svg)](https://github.com/node-modules/ylru/actions/workflows/nodejs.yml)\n[![Test coverage][codecov-image]][codecov-url]\n[![Known Vulnerabilities][snyk-image]][snyk-url]\n[![npm download][download-image]][download-url]\n\n[npm-image]: https://img.shields.io/npm/v/ylru.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/ylru\n[codecov-image]: https://img.shields.io/codecov/c/github/node-modules/ylru.svg?style=flat-square\n[codecov-url]: https://codecov.io/github/node-modules/ylru?branch=master\n[snyk-image]: https://snyk.io/test/npm/ylru/badge.svg?style=flat-square\n[snyk-url]: https://snyk.io/test/npm/ylru\n[download-image]: https://img.shields.io/npm/dm/ylru.svg?style=flat-square\n[download-url]: https://npmjs.org/package/ylru\n\n**hashlru inspired**\n\n[hashlru](https://github.com/dominictarr/hashlru) is the **Simpler, faster LRU cache algorithm.**\nPlease checkout [algorithm](https://github.com/dominictarr/hashlru#algorithm) and [complexity](https://github.com/dominictarr/hashlru#complexity) on hashlru.\n\nylru extends some features base on hashlru:\n\n- cache value can be **expired**.\n- cache value can be **empty value**, e.g.: `null`, `undefined`, `''`, `0`\n\n## Usage\n\n```ts\nimport { LRU } from 'ylru';\n\nconst lru = new LRU(100);\nlru.set(key, value);\nlru.get(key);\n\n// value2 will be expired after 5000ms\nlru.set(key2, value2, { maxAge: 5000 });\n// get key and update expired\nlru.get(key2, { maxAge: 5000 });\n```\n\n### API\n\n## new LRU(max) => lru\n\ninitialize a lru object.\n\n### lru.get(key[, options]) => value | null\n\n- `{Number} options.maxAge`: update expire time when get, value will become `undefined` after `maxAge` pass.\n\nReturns the value in the cache.\n\n### lru.set(key, value[, options])\n\n- `{Number} options.maxAge`: value will become `undefined` after `maxAge` pass.\nIf `maxAge` not set, value will be never expired.\n\nSet the value for key.\n\n### lru.keys()\n\nGet all unexpired cache keys from lru, due to the strategy of ylru, the `keys`' length may greater than `max`.\n\n```ts\nconst lru = new LRU(3);\n\nlru.set('key 1', 'value 1');\nlru.set('key 2', 'value 2');\nlru.set('key 3', 'value 3');\nlru.set('key 4', 'value 4');\n\nlru.keys(); // [ 'key 4', 'key 1', 'key 2', 'key 3']\n// cache: {\n//   'key 4': 'value 4',\n// }\n// _cache: {\n//   'key 1': 'value 1',\n//   'key 2': 'value 2',\n//   'key 3': 'value 3',\n// }\n```\n\n### lru.reset()\n\nreset a lru object.\n\n```ts\nconst lru = new LRU(3);\n\nlru.set('key 1', 'value 1');\nlru.set('key 2', 'value 2');\nlru.set('key 3', 'value 3');\nlru.set('key 4', 'value 4');\n\nlru.reset();\n// cache: {\n// }\n// _cache: {\n// }\n\nlru.keys().length === 0;\n```\n\n## License\n\n[MIT](LICENSE)\n\n<!-- GITCONTRIBUTOR_START -->\n\n## Contributors\n\n|[<img src=\"https://avatars.githubusercontent.com/u/156269?v=4\" width=\"100px;\"/><br/><sub><b>fengmk2</b></sub>](https://github.com/fengmk2)<br/>|[<img src=\"https://avatars.githubusercontent.com/u/259374?v=4\" width=\"100px;\"/><br/><sub><b>dominictarr</b></sub>](https://github.com/dominictarr)<br/>|[<img src=\"https://avatars.githubusercontent.com/u/985607?v=4\" width=\"100px;\"/><br/><sub><b>dead-horse</b></sub>](https://github.com/dead-horse)<br/>|[<img src=\"https://avatars.githubusercontent.com/u/958063?v=4\" width=\"100px;\"/><br/><sub><b>thonatos</b></sub>](https://github.com/thonatos)<br/>|[<img src=\"https://avatars.githubusercontent.com/u/25395?v=4\" width=\"100px;\"/><br/><sub><b>mourner</b></sub>](https://github.com/mourner)<br/>|[<img src=\"https://avatars.githubusercontent.com/u/32174276?v=4\" width=\"100px;\"/><br/><sub><b>semantic-release-bot</b></sub>](https://github.com/semantic-release-bot)<br/>|\n| :---: | :---: | :---: | :---: | :---: | :---: |\n[<img src=\"https://avatars.githubusercontent.com/u/6828924?v=4\" width=\"100px;\"/><br/><sub><b>vagusX</b></sub>](https://github.com/vagusX)<br/>|[<img src=\"https://avatars.githubusercontent.com/u/566097?v=4\" width=\"100px;\"/><br/><sub><b>RaoHai</b></sub>](https://github.com/RaoHai)<br/>\n\nThis project follows the git-contributor [spec](https://github.com/xudafeng/git-contributor), auto updated at `Thu Mar 28 2024 11:52:18 GMT+0800`.\n\n<!-- GITCONTRIBUTOR_END -->\n","publish_time":1711597475502,"maintainers":[{"name":"dead-horse","email":"dead_horse@qq.com"},{"name":"dead_horse","email":"dead_horse@qq.com"},{"name":"fengmk2","email":"fengmk2@gmail.com"}],"_cnpm_publish_time":1711597475502,"dist-tags":{"latest":"2.0.0","release-1.x":"1.4.0"}}