{"name":"toad-cache","description":"LRU cache for Client or Server","version":"2.0.0-next2","homepage":"https://github.com/kibertoad/toad-cache","author":{"name":"Igor Savin","email":"kibertoad@gmail.com"},"repository":{"type":"git","url":"git://github.com/kibertoad/toad-cache.git"},"bugs":{"url":"https://github.com/kibertoad/toad-cache/issues"},"license":"MIT","source":"index.js","main":"dist/toad-cache","exports":{"import":"./dist/toad-cache.js","require":"./dist/toad-cache.cjs"},"type":"module","sourceType":"module","types":"toad-cache.d.ts","engines":{"node":">=12"},"engineStrict":true,"scripts":{"build":"del-cli dist && del-cli coverage && npm run test:ci","benchmark":"node benchmark.js","changelog":"auto-changelog -p","lint":"eslint *.js src/*.js test/*.js","lint:fix":"eslint --fix *.js src/*.js test/*.js","format":"prettier --write \"{src,test}/**/*.js\" benchmark.js ","rollup":"rollup --config","test":"vitest","test:coverage":"npm run rollup && npm run test -- --coverage","test:ci":"npm run rollup && npm run lint && npm run test:coverage","types":"npx -p typescript tsc src/lru.js --declaration --allowJs --emitDeclarationOnly --outDir .","prepublishOnly":"npm run build"},"devDependencies":{"@vitest/coverage-c8":"0.29.8","@rollup/plugin-terser":"^0.4.0","auto-changelog":"^2.4.0","del-cli":"^5.0.0","eslint":"^8.38.0","eslint-config-prettier":"^8.8.0","eslint-plugin-import":"^2.27.5","eslint-plugin-prettier":"^4.2.1","precise":"^2.0.1","rollup":"^3.20.2","vitest":"0.29.8","typescript":"^5.0.4"},"keywords":["LRU","FIFO","cache","client","server","least","recently","used","first","browser"],"readme":"# Toad Cache\n\n![](https://github.com/kibertoad/toad-cache/workflows/ci/badge.svg)\n[![Coverage Status](https://coveralls.io/repos/kibertoad/toad-cache/badge.svg?branch=main)](https://coveralls.io/r/kibertoad/toad-cache?branch=main)\n\nLeast-Recently-Used and First-In-First-Out caches for Client or Server.\n\n## Getting started\n\n```javascript\nimport { lru } from \"toad-cache\";\nconst cache = lru(max, ttl = 0);\n```\n\n## clear\n### Method\n\nClears the contents of the cache\n\n**Example**\n\n```javascript\ncache.clear();\n```\n\n## delete\n### Method\n\nRemoves item from cache\n\n\tparam  {String} key Item key\n\n**Example**\n\n```javascript\ncache.delete(\"myKey\");\n```\n\n## evict\n### Method\n\nEvicts the least recently used item from cache\n\n**Example**\n\n```javascript\ncache.evict();\n```\n\n## expiresAt\n### Method\n\nGets expiration time for cached item\n\n\tparam  {String} key Item key\n\treturn {Mixed}      Undefined or number (epoch time)\n\n**Example**\n\n```javascript\nconst item = cache.expiresAt(\"myKey\");\n```\n\n## first\n### Property\n\nItem in \"first\" or \"bottom\" position\n\n**Example**\n\n```javascript\nconst cache = lru();\n\ncache.first; // null - it's a new cache!\n```\n\n## get\n### Method\n\nGets cached item and moves it to the front\n\n\tparam  {String} key Item key\n\treturn {Mixed}      Undefined or Item value\n\n**Example**\n\n```javascript\nconst item = cache.get(\"myKey\");\n```\n\n## keys\n### Method\n\nReturns an `Array` of cache item keys.\n\n\treturn {Array} Array of keys\n\n**Example**\n\n```javascript\nconsole.log(cache.keys());\n```\n\n## max\n### Property\n\nMax items to hold in cache (1000)\n\n**Example**\n\n```javascript\nconst cache = lru(500);\n\ncache.max; // 500\n```\n\n## last\n### Property\n\nItem in \"last\" or \"top\" position\n\n**Example**\n\n```javascript\nconst cache = lru();\n\ncache.last; // null - it's a new cache!\n```\n\n## set\n### Method\n\nSets item in cache as `first`\n\n\tparam  {String} key   Item key\n\tparam  {Mixed}  value Item value\n\n**Example**\n\n```javascript\ncache.set(\"myKey\", { prop: true });\n```\n\n## size\n### Property\n\nNumber of items in cache\n\n**Example**\n\n```javascript\nconst cache = lru();\n\ncache.size; // 0 - it's a new cache!\n```\n\n## ttl\n### Property\n\nMilliseconds an item will remain in cache; lazy expiration upon next `get()` of an item\n\n**Example**\n\n```javascript\nconst cache = lru();\n\ncache.ttl = 3e4;\n```\n\n## License\nCopyright (c) 2023 Igor Savin\n\nBased on [tiny-lru](https://github.com/avoidwork/tiny-lru), created by Jason Mulligan\n\nLicensed under the MIT license.\n","readmeFilename":"README.md","gitHead":"c98360aa15734c33b88c3d8eed086c1fc2f0975f","_id":"toad-cache@2.0.0-next2","_nodeVersion":"19.8.1","_npmVersion":"9.5.1","dist":{"integrity":"sha512-YfdZWqnqXO7fb+2q9cEizCqXNZxXSBejnH/RZbjHPfeqMHpN0fOlbRo8kZZP1Rmd8vB3rMTODpo2ikE/qjO6Sw==","shasum":"30818858f5dab747ece7548b62730361b1a87f1f","tarball":"http://registry-npm.ywwl.com/toad-cache/download/toad-cache-2.0.0-next2.tgz","fileCount":11,"unpackedSize":70968,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDeKwq29cMfJANkqbOA6KpEtPuV/dtSJE2vZbw+orh2KwIga9pW8RA5Hr9qmj775jWHbBrvtHr/QCOLXcf/ePlIvhU="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkMXDSACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmrq/w/9HHChJHBrSAaBAux1sLIN+RrX0N/2K4MOYJ66PQNCIC2VqO9S\r\ndO2V7i0LeP468PMdkBn5APY9kLoLpSX7T0qn7FXO6Kci4/f4NsDUTfekuOA4\r\nKRX75KXmN8nEgFd8gSIi+5gxcym6WnFW98WwQc6GXYMEjXddoU+l9D9HYiJu\r\nP8SgQ4s6iYFe1k2ptqE+JLwFeXFdiGyeiXk8hddGxwM670qliQjpYMmKZMQo\r\nwFymh789sbvD9bKoMV3YXYNQfJXABWDAp2o2p+D/hw99pvnPQp2hJsPt1C0l\r\nHorDAoolzHxaVmOIVFqZkaJ2SDVdRuJrnJdZRTqWemD0bTddYNTBhwx6i4dg\r\nkNVV5iy+4oU/LbaP6SDfEiFfYtvvqMsug1/2W1ni8YrLqdQeQ/oi18z8A/BU\r\nVQNpYRZXygyA3QV69qHaCPhy4Sm4mAgqPf93rabNJhHb16VgY7v7zjPo/TfO\r\nRVLwUfyYSwn7FLoGrWxo8gmilvsXqwZjQf39YhAwWFf8mv3x/c8ig0+FQJz2\r\nIuyR/ACai2tSiqUKuovzlR9tTo9noJIQj437E1C6l7MKLCOU6c+OWy2GrAE6\r\nUe4dXEO9p3tZty+qgFyap2qEHNTiFUatyLOOjgHk/L9JlzIbSZwYdBeAvsYW\r\nX+efRiO3ttIYjjiiRruuUXrJvPXCfit117U=\r\n=xgL8\r\n-----END PGP SIGNATURE-----\r\n","size":8077,"noattachment":false,"key":"/toad-cache/-/toad-cache-2.0.0-next2.tgz"},"_npmUser":{"name":"kibertoad","email":"iselwin@gmail.com"},"directories":{},"maintainers":[{"name":"kibertoad","email":"iselwin@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/toad-cache_2.0.0-next2_1680961745925_0.3398819502746582"},"_hasShrinkwrap":false,"publish_time":1680961746109,"_cnpm_publish_time":1680961746109,"dist-tags":{"latest":"3.7.4","next":"3.3.1-RC7"}}