{"name":"ylru","version":"0.0.1","author":{"name":"fengmk2"},"license":"MIT","_id":"ylru@0.0.1","homepage":"https://github.com/node-modules/ylru","bugs":{"url":"https://github.com/node-modules/ylru/issues"},"ci":{"version":"4, 6, 7"},"dist":{"shasum":"2fb1b48e801f80f3a539c5db6549ddb3f83e9c8d","tarball":"http://registry-npm.ywwl.com/ylru/download/ylru-0.0.1.tgz","integrity":"sha512-VdhFp8Kvlhv6mQDTuuo9QHT4yhge51NMwQdKdABlbLZrBgzAN4/v6oQmSx/MB4fCeAKM6Dz3TLqE7xfaglRGqQ==","signatures":[{"sig":"MEUCIQCxX5lPZ6hYH304/+b3yJTF3bUohveWyRaJoS5d30HlLAIgMv4lWEXsUXrZoV++HrZ+XBl4G9UfgBl05Nr4ahzVo+o=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"size":2030,"noattachment":false,"key":"/ylru/-/ylru-0.0.1.tgz"},"main":"index.js","_from":".","files":["index.js"],"_shasum":"2fb1b48e801f80f3a539c5db6549ddb3f83e9c8d","engines":{"node":">= 4.0.0"},"gitHead":"29ac7961bb122735039ec57ef7719638cb02ced4","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","autod":"autod","test-local":"egg-bin test"},"_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"repository":{"url":"git://github.com/node-modules/ylru.git","type":"git"},"_npmVersion":"3.10.8","description":"Extends LRU base on hashlru","directories":{},"_nodeVersion":"7.0.0-nightly20161228ddd22d6204","dependencies":{},"devDependencies":{"egg-ci":"^1.1.0","eslint":"^3.12.2","egg-bin":"^1.10.0","ko-sleep":"^1.0.2","eslint-config-egg":"^3.2.0"},"_npmOperationalInternal":{"tmp":"tmp/ylru-0.0.1.tgz_1482996060114_0.11768422438763082","host":"packages-12-west.internal.npmjs.com"},"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":1482996060334,"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":1482996060334,"dist-tags":{"latest":"2.0.0","release-1.x":"1.4.0"}}