Micro JavaScript library (v1.0.2, last updated 2018) that wraps localStorage or sessionStorage to provide expiration times on stored items. Items are stored with an additional key tracking expiration; fetching expired items removes them and returns null. Offers basic set/get with TTL in seconds, plus extended methods like getTimeLeft, isExpired, peek, updateExpiration, clearExpired, and JSON helpers. Accepts custom storage backends that implement localStorage API. No dependencies, minimal footprint. Not actively maintained; use as-is for legacy projects.
npm install expired-storageNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic usage of ExpiredStorage: create instance, set/get items with expiration, peek, JSON methods, and clearing expired items.
Avoid manually setting any localStorage keys that start with '__expired__'.
Provide a `keys()` function in your custom storage object that returns an array of all keys.
Always check for both null and -1 when interpreting time left. Consider using `isExpired()` first.
For new projects, consider using localforage with expiration plugin or similar.
Ensure you create an instance with `new ExpiredStorage()`. In Node.js, provide a custom storage object that implements setItem/getItem/removeItem/clear.
In browsers, include the script via <script src="dist/expired-storage.min.js"></script> and use window.ExpiredStorage. In Node, use require('expired-storage').default or import.Add a `keys()` function to your custom storage that returns an array of keys. For localStorage, this works out of the box.
No dependency data recorded yet.