Loading homepage
Add time-to-live support to localStorage with lazy expiry and an injectable storage adapter and clock.
Input: const cache = new ExpiringStorage(); cache.setItem("settings", { theme: "dark" }, 60000); cache.getItem("settings"); Output: { theme: "dark" } before expiry, null at or after expiry.
Input: cache.setItem("count", 0, 1000); cache.getItem("count"); Output: 0 before expiry.
Implement the exported class in index.js or index.ts. Tests provide fixtures for the required behavior.