v1.8.0
Now you can use ESM in browser, see this demo
<!-- unpkg -->
<script type="module">
import TuaStorage from 'https://unpkg.com/tua-storage/dist/tua-storage.esm.browser.js'
const tuaStorage = new TuaStorage({
storageEngine: localStorage,
})
tuaStorage
.load({
key: 'test',
syncFn: () => Promise.resolve('test data'),
})
.then(console.log)
.catch(console.error)
</script>
<!-- jsdelivr -->
<script type="module">
import TuaStorage from 'https://cdn.jsdelivr.net/npm/tua-storage/dist/tua-storage.esm.browser.js'
const tuaStorage = new TuaStorage({
storageEngine: localStorage,
})
tuaStorage
.load({
key: 'test',
syncFn: () => Promise.resolve('test data'),
})
.then(console.log)
.catch(console.error)
</script>
Bug Fixes
- fix: avoid sending request twice, avoid using key as cacheData
Enhancements
- feat: esm in browser (#29)