* Store data to the current storage. * @public
(options?: T)
| 900 | * @public |
| 901 | */ |
| 902 | async store<T extends StorageOptions>(options?: T) { |
| 903 | if (this._isStoring) return; |
| 904 | this._isStoring = true; |
| 905 | // We use a 1ms timeout to defer the cleanup to the next tick of the event loop. |
| 906 | // This prevents a race condition where a store operation, like 'sync:content', |
| 907 | // might increase the dirty count before it can be properly cleared. |
| 908 | setTimeout(() => { |
| 909 | this.clearDirtyCount(); |
| 910 | }, 1); |
| 911 | const data = this.storeData(); |
| 912 | await this.Storage.store(data, options); |
| 913 | setTimeout(() => { |
| 914 | this._isStoring = false; |
| 915 | }, 1); |
| 916 | return data; |
| 917 | } |
| 918 | |
| 919 | /** |
| 920 | * Load data from the current storage. |
no test coverage detected