You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By default, cleanup operations only remove expired items but do not modify existing unwrapped values. You can control whether cleanup should wrap existing unwrapped items with the `wrapUnwrappedItems` option.
79
+
80
+
```javascript
81
+
// Only clean up expired items, leave unwrapped items as-is (default)
82
+
constcleanupOnly=cleanupFactory(localStorage, {
83
+
expiresInSeconds:3600,
84
+
});
85
+
86
+
// Clean up expired items AND wrap unwrapped items
This gives you fine-grained control over when existing data gets wrapped with expiration metadata.
94
+
70
95
## Browser Idle Cleanup
71
96
72
-
The library includes support for running cleanup operations when the browser is idle, using the `requestIdleCallback` API when available, with a simple polyfill fallback for older browsers.
97
+
By default, the library runs cleanup operations when the browser is idle, using the `requestIdleCallback` API when available, with a simple polyfill fallback for older browsers.
73
98
74
99
```javascript
75
-
// Cleanup will run when browser is idle
100
+
// Cleanup will run when browser is idle (default behavior)
76
101
constidleCleanup=cleanupFactory(localStorage, {
77
102
expiresInSeconds:3600,
78
-
runWhenBrowserIsIdle:true,
79
103
});
80
104
81
105
idleCleanup.runCleanup(); // Schedules cleanup for when browser is idle
0 commit comments