{"_id":"@darco2903/expiry-cache","_rev":"7-e1c402c2ec0dbd31299cf52151a3eec6","name":"@darco2903/expiry-cache","dist-tags":{"beta":"2.0.0-beta.0","latest":"3.0.1"},"versions":{"2.0.0-beta.0":{"name":"@darco2903/expiry-cache","version":"2.0.0-beta.0","keywords":[],"author":{"name":"Darco2903"},"license":"ISC","_id":"@darco2903/expiry-cache@2.0.0-beta.0","maintainers":[{"name":"darco2903","email":"william.valenduc@orange.fr"}],"homepage":"https://github.com/Darco2903/expiry-cache#readme","bugs":{"url":"https://github.com/Darco2903/expiry-cache/issues"},"dist":{"shasum":"50b034383df7b8220488ee967d9f078aa7cb5f11","tarball":"https://registry.npmjs.org/@darco2903/expiry-cache/-/expiry-cache-2.0.0-beta.0.tgz","fileCount":12,"integrity":"sha512-QW+BL/S7KT5hUcXlhQHXvkrkJIuJeZ8liCJzzaH78eEvDd0NKF+KMdPWGXBsvouzhls5n1ermHgt52ScHucBWQ==","signatures":[{"sig":"MEYCIQCMOjSGw5DWVqxnWuw3d/IUcL0hVJf6EFE5JxpRXWM3fgIhALjDLhOrP+flTEggItihnCaHeZTFVUqeOjOBouJ5+gKD","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":16348},"main":"dist/index.js","type":"module","_from":"file:darco2903-expiry-cache-2.0.0-beta.0.tgz","types":"dist/index.d.ts","scripts":{"test":"vitest","build":"tsc","clean":"rimraf -g dist darco2903-expiry-cache-*.tgz","test:ui":"vitest --ui"},"_npmUser":{"name":"darco2903","email":"william.valenduc@orange.fr"},"_resolved":"C:\\Users\\Will\\AppData\\Local\\Temp\\6304c8db840417f84c43f0175024c067\\darco2903-expiry-cache-2.0.0-beta.0.tgz","_integrity":"sha512-QW+BL/S7KT5hUcXlhQHXvkrkJIuJeZ8liCJzzaH78eEvDd0NKF+KMdPWGXBsvouzhls5n1ermHgt52ScHucBWQ==","repository":{"url":"git+https://github.com/Darco2903/expiry-cache.git"},"_npmVersion":"11.6.2","description":"A simple in-memory cache with expiry functionality. It allows you to store data that automatically expires after a specified duration, with support for synchronous and asynchronous data fetching.","directories":{},"_nodeVersion":"24.11.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"rimraf":"^6.1.0","vitest":"^3.2.4","@vitest/ui":"^3.2.4","typescript":"^5.9.3","@darco2903/web-common":"^0.7.0"},"peerDependencies":{"@darco2903/secondthought":"^1.1.0"},"_npmOperationalInternal":{"tmp":"tmp/expiry-cache_2.0.0-beta.0_1772736669464_0.08293280665445835","host":"s3://npm-registry-packages-npm-production"}},"2.0.0":{"name":"@darco2903/expiry-cache","version":"2.0.0","keywords":[],"author":{"name":"Darco2903"},"license":"ISC","_id":"@darco2903/expiry-cache@2.0.0","maintainers":[{"name":"darco2903","email":"william.valenduc@orange.fr"}],"homepage":"https://github.com/Darco2903/expiry-cache#readme","bugs":{"url":"https://github.com/Darco2903/expiry-cache/issues"},"dist":{"shasum":"8c5313cf67330829d57aff64d3bde5e9915bb5d3","tarball":"https://registry.npmjs.org/@darco2903/expiry-cache/-/expiry-cache-2.0.0.tgz","fileCount":12,"integrity":"sha512-hvPkXsvxlW6lMgRXPv55NXUDK1VYTL8f2+fdxYQiSVI2DYaiLmBX1zqa9EdrqJpabBJ9KymNs//ZwxHW9AJfgg==","signatures":[{"sig":"MEUCIE2iBdz7rIf0JWbODZjFj9AJEt5u2YR5fe3Uv4msz9d1AiEAx/tzWQEmUCBy0cuEO5qiTKf9V9zKBrH/XwsEGgZ+ocs=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@darco2903%2fexpiry-cache@2.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":16271},"main":"dist/index.js","type":"module","_from":"file:darco2903-expiry-cache-2.0.0.tgz","types":"dist/index.d.ts","scripts":{"test":"vitest","build":"tsc","clean":"rimraf -g dist darco2903-expiry-cache-*.tgz","test:ui":"vitest --ui"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:9c5f2a86-8f89-4938-a6e9-938310160f6c"}},"_resolved":"/tmp/5a555da1df0cfe325c2c3e436e6f9df5/darco2903-expiry-cache-2.0.0.tgz","_integrity":"sha512-hvPkXsvxlW6lMgRXPv55NXUDK1VYTL8f2+fdxYQiSVI2DYaiLmBX1zqa9EdrqJpabBJ9KymNs//ZwxHW9AJfgg==","repository":{"url":"git+https://github.com/Darco2903/expiry-cache.git"},"_npmVersion":"11.9.0","description":"A simple in-memory cache with expiry functionality. It allows you to store data that automatically expires after a specified duration, with support for synchronous and asynchronous data fetching.","directories":{},"_nodeVersion":"24.14.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"rimraf":"^6.1.0","vitest":"^3.2.4","@vitest/ui":"^3.2.4","typescript":"^5.9.3","@darco2903/web-common":"^0.7.0"},"peerDependencies":{"@darco2903/secondthought":"^1.1.0"},"_npmOperationalInternal":{"tmp":"tmp/expiry-cache_2.0.0_1772736850454_0.45513736487519263","host":"s3://npm-registry-packages-npm-production"}},"2.0.1":{"name":"@darco2903/expiry-cache","version":"2.0.1","keywords":[],"author":{"name":"Darco2903"},"license":"ISC","_id":"@darco2903/expiry-cache@2.0.1","maintainers":[{"name":"darco2903","email":"william.valenduc@orange.fr"}],"homepage":"https://github.com/Darco2903/expiry-cache#readme","bugs":{"url":"https://github.com/Darco2903/expiry-cache/issues"},"dist":{"shasum":"43ce41ad5a4ab7b52dce0ed2ef71703b1223daa7","tarball":"https://registry.npmjs.org/@darco2903/expiry-cache/-/expiry-cache-2.0.1.tgz","fileCount":13,"integrity":"sha512-kLVy7ormE8BIeCbnPbFxiI2JkTGZO2ZsmVJ+3oSEgh2R+syfw2oEG+eZNiij1kLNeQoiTeaw1UXtssEBEp970w==","signatures":[{"sig":"MEUCIQD12aiIGYJFuZzCYcbd+USYKf12bO077OcJnjX1SAVUIwIgQp35KC1SVvTn5YoFWr05rd80YUqDocCF//J5hStYHmM=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@darco2903%2fexpiry-cache@2.0.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":51701},"main":"dist/index.js","type":"module","_from":"file:darco2903-expiry-cache-2.0.1.tgz","types":"dist/index.d.ts","scripts":{"test":"vitest","build":"tsc","clean":"rimraf -g dist darco2903-expiry-cache-*.tgz","test:ui":"vitest --ui"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:9c5f2a86-8f89-4938-a6e9-938310160f6c"}},"_resolved":"/tmp/1af305fc9e20db2ecb264dfad54958b0/darco2903-expiry-cache-2.0.1.tgz","_integrity":"sha512-kLVy7ormE8BIeCbnPbFxiI2JkTGZO2ZsmVJ+3oSEgh2R+syfw2oEG+eZNiij1kLNeQoiTeaw1UXtssEBEp970w==","repository":{"url":"git+https://github.com/Darco2903/expiry-cache.git"},"_npmVersion":"11.9.0","description":"A simple in-memory cache with expiry functionality. It allows you to store data that automatically expires after a specified duration, with support for synchronous and asynchronous data fetching.","directories":{},"_nodeVersion":"24.14.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"rimraf":"^6.1.0","vitest":"^3.2.4","@vitest/ui":"^3.2.4","typescript":"^5.9.3","@darco2903/web-common":"^0.7.0"},"peerDependencies":{"@darco2903/secondthought":"^1.1.0"},"_npmOperationalInternal":{"tmp":"tmp/expiry-cache_2.0.1_1772747849543_0.4603382484179035","host":"s3://npm-registry-packages-npm-production"}},"2.0.2":{"name":"@darco2903/expiry-cache","version":"2.0.2","keywords":[],"author":{"name":"Darco2903"},"license":"ISC","_id":"@darco2903/expiry-cache@2.0.2","maintainers":[{"name":"darco2903","email":"william.valenduc@orange.fr"}],"homepage":"https://github.com/Darco2903/expiry-cache#readme","bugs":{"url":"https://github.com/Darco2903/expiry-cache/issues"},"dist":{"shasum":"1bd9fa99eafa40982a1481c1964a09e91cc0af5f","tarball":"https://registry.npmjs.org/@darco2903/expiry-cache/-/expiry-cache-2.0.2.tgz","fileCount":13,"integrity":"sha512-i8GGG1FiL1xfoz0Rfu29RFVWi98YuF4W2TYtnwkwrDpEkyIsz35ePbVJGT5IARkuvRMfWGeN13X0njPEW/KBVA==","signatures":[{"sig":"MEYCIQDIeb4Nef6EXtgPUfIGUALEL0cTjQnnk3uZwaAWPFisrgIhAN3nuAI39LmtKa07s4Hs2+qaBRVJ8aRpFEML7KglSLxK","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@darco2903%2fexpiry-cache@2.0.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":19069},"main":"dist/index.js","type":"module","_from":"file:darco2903-expiry-cache-2.0.2.tgz","types":"dist/index.d.ts","scripts":{"test":"vitest","build":"tsc","clean":"rimraf -g dist darco2903-expiry-cache-*.tgz","test:ui":"vitest --ui"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:9c5f2a86-8f89-4938-a6e9-938310160f6c"}},"_resolved":"/tmp/2b0f6d44a28d67f96a4cb91439b38a40/darco2903-expiry-cache-2.0.2.tgz","_integrity":"sha512-i8GGG1FiL1xfoz0Rfu29RFVWi98YuF4W2TYtnwkwrDpEkyIsz35ePbVJGT5IARkuvRMfWGeN13X0njPEW/KBVA==","repository":{"url":"git+https://github.com/Darco2903/expiry-cache.git"},"_npmVersion":"11.9.0","description":"A simple in-memory cache with expiry functionality. It allows you to store data that automatically expires after a specified duration, with support for synchronous and asynchronous data fetching.","directories":{},"_nodeVersion":"24.14.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"rimraf":"^6.1.0","vitest":"^3.2.4","@vitest/ui":"^3.2.4","typescript":"^5.9.3","@darco2903/web-common":"^0.7.0"},"peerDependencies":{"@darco2903/secondthought":"^1.3.0"},"_npmOperationalInternal":{"tmp":"tmp/expiry-cache_2.0.2_1773548718967_0.13933657208275885","host":"s3://npm-registry-packages-npm-production"}},"2.1.0":{"name":"@darco2903/expiry-cache","version":"2.1.0","keywords":[],"author":{"name":"Darco2903"},"license":"ISC","_id":"@darco2903/expiry-cache@2.1.0","maintainers":[{"name":"darco2903","email":"william.valenduc@orange.fr"}],"homepage":"https://github.com/Darco2903/expiry-cache#readme","bugs":{"url":"https://github.com/Darco2903/expiry-cache/issues"},"dist":{"shasum":"918dc92afb958bb43a569cac067ae311f7c86166","tarball":"https://registry.npmjs.org/@darco2903/expiry-cache/-/expiry-cache-2.1.0.tgz","fileCount":13,"integrity":"sha512-Y4BuO9IRSFN29huk5EnEQtBnzLuqvVG7mttLang85R2Vt1tKtXGwEI+rx29g7VLlD000LCpX5038SzCazow2qQ==","signatures":[{"sig":"MEUCIAOAU4rZUuHz4uWqTiyD6WIsGofxkG4hna35fbGZ+QicAiEA4tIcmp8OEpQhzJCVwanoeGnJ4NvzIyvKbUiIG9N0uEI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@darco2903%2fexpiry-cache@2.1.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":20941},"main":"dist/index.js","type":"module","_from":"file:darco2903-expiry-cache-2.1.0.tgz","types":"dist/index.d.ts","scripts":{"test":"vitest","build":"tsc","clean":"rimraf -g dist darco2903-expiry-cache-*.tgz","test:ui":"vitest --ui"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:9c5f2a86-8f89-4938-a6e9-938310160f6c"}},"_resolved":"/tmp/d633ee48e47095032ff54d177231e1a1/darco2903-expiry-cache-2.1.0.tgz","_integrity":"sha512-Y4BuO9IRSFN29huk5EnEQtBnzLuqvVG7mttLang85R2Vt1tKtXGwEI+rx29g7VLlD000LCpX5038SzCazow2qQ==","repository":{"url":"git+https://github.com/Darco2903/expiry-cache.git"},"_npmVersion":"11.9.0","description":"A simple in-memory cache with expiry functionality. It allows you to store data that automatically expires after a specified duration, with support for synchronous and asynchronous data fetching.","directories":{},"_nodeVersion":"24.14.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"rimraf":"^6.1.0","vitest":"^3.2.4","@vitest/ui":"^3.2.4","typescript":"^5.9.3","@darco2903/web-common":"^0.7.0"},"peerDependencies":{"@darco2903/secondthought":"^1.3.0"},"_npmOperationalInternal":{"tmp":"tmp/expiry-cache_2.1.0_1773585627574_0.2961823900793199","host":"s3://npm-registry-packages-npm-production"}},"3.0.0":{"name":"@darco2903/expiry-cache","version":"3.0.0","keywords":[],"author":{"name":"Darco2903"},"license":"ISC","_id":"@darco2903/expiry-cache@3.0.0","maintainers":[{"name":"darco2903","email":"william.valenduc@orange.fr"}],"homepage":"https://github.com/Darco2903/expiry-cache#readme","bugs":{"url":"https://github.com/Darco2903/expiry-cache/issues"},"dist":{"shasum":"4dc8b2cb4722659ed1105d846e105dc2c1b82b0f","tarball":"https://registry.npmjs.org/@darco2903/expiry-cache/-/expiry-cache-3.0.0.tgz","fileCount":43,"integrity":"sha512-8WcsdX6n6KvrXeCAKhlSMaIeAFs1UG2+bM8STAPG7YS+9TPzBQhsSqYtr9lcmR/bZ1TwJXyABcqYUh8nEAFnXQ==","signatures":[{"sig":"MEQCIB3PKZCvM+seC/5Y4XWMrak5b2nWtlaZR870wh295Lr4AiA+V0voGpJic03oFtY0exR8fXXHN4BYl/CwWR4HfMZVWA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@darco2903%2fexpiry-cache@3.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":39111},"main":"dist/index.js","type":"module","_from":"file:darco2903-expiry-cache-3.0.0.tgz","types":"dist/index.d.ts","scripts":{"test":"vitest","build":"tsc","clean":"rimraf -g dist darco2903-expiry-cache-*.tgz"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:9c5f2a86-8f89-4938-a6e9-938310160f6c"}},"_resolved":"/tmp/5b80d97b8e538a5c526a472521b4c2f2/darco2903-expiry-cache-3.0.0.tgz","_integrity":"sha512-8WcsdX6n6KvrXeCAKhlSMaIeAFs1UG2+bM8STAPG7YS+9TPzBQhsSqYtr9lcmR/bZ1TwJXyABcqYUh8nEAFnXQ==","repository":{"url":"git+https://github.com/Darco2903/expiry-cache.git"},"_npmVersion":"11.9.0","description":"A simple in-memory cache with expiry functionality. It allows you to store data that automatically expires after a specified duration, with support for synchronous and asynchronous data fetching.","directories":{},"_nodeVersion":"24.14.0","dependencies":{"@darco2903/typed-emitter":"^1.3.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"rimraf":"^6.1.3","vitest":"^3.2.4","typescript":"^5.9.3","@types/node":"^25.5.0","@darco2903/web-common":"^0.7.0"},"peerDependencies":{"neverthrow":"^8.2.0","@darco2903/secondthought":"^1.3.0"},"_npmOperationalInternal":{"tmp":"tmp/expiry-cache_3.0.0_1774021565281_0.31129137314965405","host":"s3://npm-registry-packages-npm-production"}},"3.0.1":{"name":"@darco2903/expiry-cache","version":"3.0.1","author":{"name":"Darco2903"},"description":"A simple in-memory cache with expiry functionality. It allows you to store data that automatically expires after a specified duration, with support for synchronous and asynchronous data fetching.","keywords":[],"license":"ISC","main":"dist/index.js","types":"dist/index.d.ts","type":"module","repository":{"url":"git+https://github.com/Darco2903/expiry-cache.git"},"publishConfig":{"access":"public"},"dependencies":{"@darco2903/secondthought":"^1.3.0","@darco2903/typed-emitter":"^1.3.1"},"peerDependencies":{"neverthrow":"^8.2.0"},"devDependencies":{"@darco2903/web-common":"^0.7.0","@types/node":"^25.5.0","rimraf":"^6.1.3","typescript":"^5.9.3","vitest":"^3.2.4"},"scripts":{"build":"tsc","test":"vitest","clean":"rimraf -g dist darco2903-expiry-cache-*.tgz"},"_id":"@darco2903/expiry-cache@3.0.1","bugs":{"url":"https://github.com/Darco2903/expiry-cache/issues"},"homepage":"https://github.com/Darco2903/expiry-cache#readme","_integrity":"sha512-Z3i7vxeNie1meGTyBYpgOXLyBMNwhvYPQDMDbXaKvA7KRBjrKkP7FHZkSQChBS+DhBvWLTlITva4LctgMJnB4A==","_resolved":"/tmp/912edbbddb19f2253324c9943b02583d/darco2903-expiry-cache-3.0.1.tgz","_from":"file:darco2903-expiry-cache-3.0.1.tgz","_nodeVersion":"24.14.0","_npmVersion":"11.9.0","dist":{"integrity":"sha512-Z3i7vxeNie1meGTyBYpgOXLyBMNwhvYPQDMDbXaKvA7KRBjrKkP7FHZkSQChBS+DhBvWLTlITva4LctgMJnB4A==","shasum":"09d5013145847a766cbc81197bf2fa14253eb606","tarball":"https://registry.npmjs.org/@darco2903/expiry-cache/-/expiry-cache-3.0.1.tgz","fileCount":43,"unpackedSize":39111,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@darco2903%2fexpiry-cache@3.0.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDRzhGnIrvebmFP7Ah4ThPuZam9SSJgu8vxqgh49wvIeAIgUWCs6AXnzTwVhoFFu3K1t52sK0yX+/KlA+ARJj/uivs="}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:9c5f2a86-8f89-4938-a6e9-938310160f6c"}},"directories":{},"maintainers":[{"name":"darco2903","email":"william.valenduc@orange.fr"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/expiry-cache_3.0.1_1774108976988_0.4810474389200008"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-05T18:51:09.331Z","modified":"2026-03-21T16:02:57.420Z","2.0.0-beta.0":"2026-03-05T18:51:09.635Z","2.0.0":"2026-03-05T18:54:10.593Z","2.0.1":"2026-03-05T21:57:29.705Z","2.0.2":"2026-03-15T04:25:19.103Z","2.1.0":"2026-03-15T14:40:27.735Z","3.0.0":"2026-03-20T15:46:05.437Z","3.0.1":"2026-03-21T16:02:57.132Z"},"bugs":{"url":"https://github.com/Darco2903/expiry-cache/issues"},"author":{"name":"Darco2903"},"license":"ISC","homepage":"https://github.com/Darco2903/expiry-cache#readme","keywords":[],"repository":{"url":"git+https://github.com/Darco2903/expiry-cache.git"},"description":"A simple in-memory cache with expiry functionality. It allows you to store data that automatically expires after a specified duration, with support for synchronous and asynchronous data fetching.","maintainers":[{"name":"darco2903","email":"william.valenduc@orange.fr"}],"readme":"# Expiry Cache\n\n## Description\n\nA simple in-memory cache with expiry functionality. It allows you to store data that automatically expires after a specified duration, with support for synchronous and asynchronous data fetching.\n\n> Note: This package utilizes the [**@darco2903/secondthought**](https://www.npmjs.com/package/@darco2903/secondthought) package for time-related operations, providing enhanced capabilities for handling and manipulating time-related data. While its use is not mandatory, it is recommended for optimal safety and reliability when working with time values.\n\n## Features\n\n- **Type Safety**: Strongly typed cache entries and fetcher functions.\n- **Automatic Expiry**: Cache entries automatically expire after a specified duration.\n- **Manual Expiry**: Manually expire cache entries when needed.\n- **Synchronous and Asynchronous Fetching**: Support for both synchronous and asynchronous data fetching.\n- **Safe Fetching**: Safe cache fetching that returns a `Result` type, allowing for error handling without throwing exceptions.\n- **Stale Data Access**: Option to access stale data even after it has expired.\n- **Parameterized Fetching**: Support for fetcher functions that require parameters.\n- **Return Options**: Allow to set expiry time when refreshing the cache. For exemple API tokens that return their expiry time.\n- **Event Emission**: Emit events on cache refresh and expiry for better integration with other parts of your application.\n\n## Installation\n\n```bash\nnpm install @darco2903/expiry-cache\n```\n\n## Example Usage\n\n### Basic Example\n\n```ts\nimport { ExpiryCache } from \"@darco2903/expiry-cache\";\n\nconst cache = new ExpiryCache(\"initial\", () => \"refreshed\", 1000); // ExpiryCache<string, () => string>\nconsole.log(cache.getData()); // initial\n\nawait new Promise((resolve) => setTimeout(resolve, 1100)); // wait for cache to expire\nconsole.log(cache.isExpired); // true\nconsole.log(cache.getData()); // null\nconsole.log(cache.getRawData()); // initial (returns the raw data even if expired)\n\ncache.refresh();\nconsole.log(cache.getData()); // refreshed\n\nawait new Promise((resolve) => setTimeout(resolve, 1100)); // wait for cache to expire\nconsole.log(cache.isExpired); // true\nconsole.log(cache.getDataOrRefresh()); // refreshed (refreshes the cache and returns the new value)\n\nconsole.log(cache.expirationTime); // 1000\nconsole.log(cache.expiresAt); // current timestamp + 1000 milliseconds\nconsole.log(cache.timeToLive); // time remaining until expiration in milliseconds\n\ncache.expire(); // Manually expire the cache\nconsole.log(cache.isExpired); // true\n```\n\n### With Parameters\n\nYou can also use the cache with a fetcher function that requires parameters. In this case, the `refresh` method accepts the necessary parameters to fetch the new data.\n\n```ts\nimport { ExpiryCache } from \"@darco2903/expiry-cache\";\n\nconst cache = new ExpiryCache(10, (a: number, b: number) => a + b, 200); // ExpiryCache<number, (a: number, b: number) => number>\n\ncache.refresh(5, 7); // typed: refresh(a: number, b: number)\nconsole.log(cache.getData()); // 12\n```\n\n### With Async Fetcher\n\nSame as the ExpiryCache, but with an asynchronous fetcher function. The `refresh` method will return a promise that resolves when the cache has been updated.\n\n```ts\nimport { ExpiryCacheAsync } from \"@darco2903/expiry-cache\";\n\nasync function getApiData(): Promise<string> {\n    // Simulate an API call\n    return new Promise((resolve) => {\n        setTimeout(() => {\n            resolve(\"fetched data from API\");\n        }, 500);\n    });\n}\n\nconst cache = new ExpiryCacheAsync(\"initial data\", getApiData, 5000);\n\nawait cache.refresh();\nconsole.log(cache.getData()); // fetched data from API\n```\n\n### With Result\n\nAllows to handle errors without throwing exceptions, returning a `Result` type instead. The cache will be updated only if the result is `Ok`, otherwise nothing is changed and the cache is not refreshed when the result is `Err`.\n\nIn this example, we have a fetcher function that performs a division operation. If the divisor is zero, it returns an error instead of throwing an exception.\n\n```ts\nimport { ExpiryCacheSafe } from \"@darco2903/expiry-cache\";\nimport { err, ok } from \"neverthrow\";\n\nconst cache = new ExpiryCacheSafe(1, (a: number, b: number) => (b === 0 ? err(\"Division by zero\") : ok(a / b)), 100);\nconsole.log(cache.getData()); // 1\nconsole.log(cache.timeToLiveAsTime?.toStringWithUnit()); // ~100ms\n\nawait new Promise((resolve) => setTimeout(resolve, 200));\nconsole.log(cache.isExpired); // true\n\ncache.refresh(4, 2); // ok(2)\nconsole.log(cache.getData()); // 2\nconsole.log(cache.timeToLiveAsTime?.toStringWithUnit()); // ~100ms\n\nawait new Promise((resolve) => setTimeout(resolve, 200));\nconsole.log(cache.isExpired); // true\n\ncache.refresh(4, 0); // err(\"Division by zero\")\nconsole.log(cache.getData()); // null\nconsole.log(cache.isExpired); // true\n```\n\n### Event Emission\n\n```ts\nimport { ExpiryCache } from \"@darco2903/expiry-cache\";\n\nconst cache = new ExpiryCache(0, () => 10, 1000);\ncache.on(\"expired\", () => {\n    console.log(\"Cache expired\");\n});\n\ncache.on(\"refreshed\", (value) => {\n    console.log(\"Cache refreshed with value:\", value);\n});\n\ncache.expire(); // trigger the expired event\n\ncache.refresh(); // trigger the refreshed event\n```\n\n### Setting expiry time when refreshing\n\n#### ExpiresIn\n\n```ts\nimport { ExpiryCache, ReturnOptions } from \"@darco2903/expiry-cache\";\n\nconst cache = new ExpiryCache(0, () => ReturnOptions.ExpiresIn(0, 200), 1000);\nconsole.log(cache.expirationTime); // 1000\n\ncache.refresh();\nconsole.log(cache.expirationTime); // 200\n```\n\n#### ExpiresAt\n\n```ts\nimport { ExpiryCache, ReturnOptions } from \"@darco2903/expiry-cache\";\n\nconst cache = new ExpiryCache(0, () => ReturnOptions.ExpiresAt(0, Date.now() + 200), 1000);\nconsole.log(cache.expiresAt - Date.now()); //  ~1000\n\ncache.refresh();\nconsole.log(cache.expiresAt - Date.now()); //  ~200\n```\n\n### SecondThought Integration\n\n```ts\nimport { ExpiryCache } from \"@darco2903/expiry-cache\";\nimport { Millisecond, Second, Minute, Hour } from \"@darco2903/secondthought\";\n\nconst cache = new ExpiryCache(\"data\", () => \"data\", new Minute(5)); // Cache expires in 5 minutes\n\ncache.setExpiresIn(new Hour(1)); // Update the cache to expire in 1 hour\ncache.setExpiresAt(Millisecond.now().add(new Second(2))); // Set the cache to expire in 2 seconds\n```\n\n### Full Example with Async Fetcher, Result and ReturnOptions\n\n```ts\nimport { ExpiryCacheSafeAsync, ReturnOptions } from \"@darco2903/expiry-cache\";\nimport { Second } from \"@darco2903/secondthought\";\nimport { ResultAsync, okAsync } from \"neverthrow\";\n\ntype TokenData = {\n    token: string;\n    expiresIn: number;\n};\n\nfunction fetchApiToken(): ResultAsync<TokenData, string> {\n    return ResultAsync.fromPromise(\n        fetch(\"https://example.com/api/token\").then((res) => res.json()),\n        (err) => String(err),\n    );\n}\n\nconst cache = new ExpiryCacheSafeAsync(\"\", () => {\n    return fetchApiToken().andThen((res) => {\n        return okAsync(ReturnOptions.ExpiresIn(res.token, new Second(res.expiresIn)));\n    });\n});\ncache.expire(); // expire the cache immediately to force a refresh on the first call\n\nawait cache.refresh().match(\n    (token) => {\n        console.log(\"Fetched API token:\", token);\n    },\n    (err) => {\n        console.error(\"Error fetching API token:\", err);\n    },\n);\n```\n","readmeFilename":"README.md"}