{"_id":"ttl-set","name":"ttl-set","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"ttl-set","version":"1.0.0","description":"Like a JavaScript Set, but with a TTL on entries","main":"index.js","scripts":{"test":"node test.js"},"repository":{"type":"git","url":"git+https://github.com/watson/ttl-set.git"},"keywords":["ttl","set","cache","time"],"author":{"name":"Thomas Watson","email":"w@tson.dk","url":"https://wa.tson.dk/"},"license":"MIT","bugs":{"url":"https://github.com/watson/ttl-set/issues"},"homepage":"https://github.com/watson/ttl-set#readme","dependencies":{"fast-fifo":"^1.3.2"},"_id":"ttl-set@1.0.0","gitHead":"ac7bc5c6b0506dc1b2433c043c14adcc50089a62","_nodeVersion":"22.9.0","_npmVersion":"10.9.0","dist":{"integrity":"sha512-2fuHn/UR+8Z9HK49r97+p2Ru1b5Eewg2QqPrU14BVCQ9QoyU3+vLLZk2WEiyZ9sgJh6W8G1cZr9I2NBLywAHrA==","shasum":"e7895d946ad9cedfadcf6e3384ea97322a86dd3b","tarball":"https://registry.npmjs.org/ttl-set/-/ttl-set-1.0.0.tgz","fileCount":5,"unpackedSize":4614,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIF9xlA+xHrEi/aQZp6ojSHEmJgHWQW7tA5F6v5GSU9AjAiEAvD/HSjeFX5Zh4W0+Md6knd9oOndi7h4xCZpsLCBAwBc="}]},"_npmUser":{"name":"watson","email":"w@tson.dk"},"directories":{},"maintainers":[{"name":"watson","email":"w@tson.dk"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ttl-set_1.0.0_1730840020225_0.4955646205396551"},"_hasShrinkwrap":false}},"time":{"created":"2024-11-05T20:53:40.224Z","1.0.0":"2024-11-05T20:53:40.428Z","modified":"2024-11-05T20:53:40.681Z"},"maintainers":[{"name":"watson","email":"w@tson.dk"}],"description":"Like a JavaScript Set, but with a TTL on entries","homepage":"https://github.com/watson/ttl-set#readme","keywords":["ttl","set","cache","time"],"repository":{"type":"git","url":"git+https://github.com/watson/ttl-set.git"},"author":{"name":"Thomas Watson","email":"w@tson.dk","url":"https://wa.tson.dk/"},"bugs":{"url":"https://github.com/watson/ttl-set/issues"},"license":"MIT","readme":"# ttl-set\n\nLike a JavaScript Set, but with a TTL on entries\n\n## Installation\n\n```sh\nnpm install ttl-set --save\n```\n\n## Usage\n\n```js\nconst TTLSet = require('ttl-set')\n\nconst cache = new TTLSet(60 * 1000) // TTL: 1 minute\n\ncache.add('hello')\n// ...wait 40 seconds...\ncache.add('world')\n// ...wait 40 seconds...\nconsole.log(cache.has('hello')) // => false\nconsole.log(cache.has('world')) // => true\n// ...wait 40 seconds...\nconsole.log(cache.has('world')) // => false\n```\n\n## API\n\n### `TTLSet(ttl)` constructor\n\nCreate a new instance of the TTLSet.\nTakes `ttl` as a required argument,\nwhich is the number of milliseconds for elements to live in the TTLSet before evicting them.\n\n### `TTLSet.prototype.add(value)`\n\nAdds the given `value` to the TTLSet.\n\n### `TTLSet.prototype.clear()`\n\nClear all previously added values to the TTLSet.\n\n### `TTLSet.prototype.has(value)`\n\nReturns `true` if the TTLSet contains the given `value`. Returns `false` otherwise.\n\n### `TTLSet.prototype.size`\n\nThe number of elements in the TTLSet.\n\n## License\n\nMIT","readmeFilename":"README.md"}