localStorageDB icon indicating copy to clipboard operation
localStorageDB copied to clipboard

Support Web Worker

Open fvanwijk opened this issue 9 months ago • 1 comments

I wanted to use the lib in a Web Worker but there is no window.

I believe it is as simple as adding || self.indexedDB to the line where var indexedDB is set.

fvanwijk avatar May 15 '25 13:05 fvanwijk

... no need for || -- window can be replaced by self and will continue to work and reference Window or in a service worker: WorkerGlobalScope

line 2: var win = typeof window !== 'undefined' ? window : {} -> var win = typeof self !== 'undefined' ? window : {}

line 4: if (typeof window !== 'undefined' && !indexedDB) { -> if (typeof self !== 'undefined' && !indexedDB) {

BananaAcid avatar Nov 30 '25 16:11 BananaAcid