{"name":"toad-cache","description":"LRU cache for Client or Server","version":"2.0.0-next1","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-next1","_nodeVersion":"19.8.1","_npmVersion":"9.5.1","dist":{"integrity":"sha512-F70zF4Yy019/3SEWDvake4RUCRSLWFLqXkP/oOcV8k4xkhL1Fsu6eHpMpFdc1lFIvRdwok5icbaXoJz0sgyiFA==","shasum":"68bb7d5d6d032acc1e16ab30af53e03be31d0256","tarball":"http://registry-npm.ywwl.com/toad-cache/download/toad-cache-2.0.0-next1.tgz","fileCount":11,"unpackedSize":29781,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAI9Hiu2JvAajwWQtMRtg3p3Q4rlcc3qzq/4SrtyOXcwAiEAxv+haRf0/aqcoPX64nwxQa4X1y34qCL+ZNVrnGxTtoE="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkMW/6ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqIshAAi4MczLzt+f4SqrHRd94p8oOS1HoLdzv2KInKPIWtwTpWYLhd\r\n5UKFGv7KEaCByyQdOCh5cT0ikXU6Jb6Y5ramWg0DY6SkMFsIltpkMiE2xJOu\r\nHAhby5o+MFe7x/P82Bsu4TrhYSexSmzA0hrJ/ZLEiV2GbYHTNN7akZE7JoNd\r\n+Ju92r+a27zvUSLV7ZnuA8ZZMVtShzw7rNbmER/OQPWvrmfNhoC9snmVniyO\r\nBnqZ4Up8qYsiACdABZ7BtzyWk72ECRUA4GMsScuv4RsNA52k3jGYb2BtvMXn\r\nUo096kY8/bx17Y/KjkkwCl/yd00RIN1dZG+kKPJvIMvPDleYWoErl1pQZQpY\r\nBSO2f9CxqYHXrqBNL5DKC8QZfJi1e5eGp7L368R4SpNjk0B0sD1c5XHpGvVP\r\nRGwJpNIQvzK4ePXfrr2Rr9TgK0Wceh2459T5HfAQsCsoW5cVTbHu32dKuQ9y\r\nAzB8nXeKnayZEgtDwl5RzdSLifPnVTEe83PgGA/q+Y4VdHGpZD05vnOez42O\r\no4cBim/qz9NunKT0sEyQVpxsacuB1RYv4+T7EyleO0pDpk/1SWFC6jgDG6py\r\njzFz/vReBzfo0B3JpSFCz1H0GvZw2BAH5HqM3Ao4dx04nUaKwuiBrBAJuntB\r\n5a/JlMCUewRG7hlKie2NKs0qWT5MHRF2wOM=\r\n=tJh8\r\n-----END PGP SIGNATURE-----\r\n","size":6216,"noattachment":false,"key":"/toad-cache/-/toad-cache-2.0.0-next1.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-next1_1680961530109_0.9007213877127616"},"_hasShrinkwrap":false,"publish_time":1680961530311,"_cnpm_publish_time":1680961530311,"dist-tags":{"latest":"3.7.4","next":"3.3.1-RC7"}}