Compare commits

...

11 Commits

Author SHA1 Message Date
12119192cf update description 2024-05-29 14:17:47 +02:00
ed0f497ac9 2.0.20 2024-05-28 01:00:35 +02:00
7f7c4a28ee fix(core): update 2024-05-28 01:00:35 +02:00
4ee78554a4 2.0.19 2024-05-25 02:02:45 +02:00
34b90b438c fix(core): update 2024-05-25 02:02:44 +02:00
40dcedf585 2.0.18 2024-05-25 02:02:00 +02:00
d630bd90a4 fix(core): update 2024-05-25 02:01:59 +02:00
56d9072996 2.0.17 2024-05-17 17:46:56 +02:00
ed1c977387 fix(core): update 2024-05-17 17:46:56 +02:00
7425a5c42d 2.0.16 2024-05-17 16:36:57 +02:00
65d5d1f6d3 fix(core): update 2024-05-17 16:36:56 +02:00
6 changed files with 234 additions and 47 deletions

View File

@ -5,7 +5,7 @@
"githost": "code.foss.global",
"gitscope": "push.rocks",
"gitrepo": "webstore",
"description": "high performance storage in the browser using indexed db",
"description": "A high-performance storage solution for web applications using IndexedDB.",
"npmPackagename": "@push.rocks/webstore",
"license": "MIT",
"projectDomain": "push.rocks",
@ -19,7 +19,9 @@
"data persistence",
"storage solution",
"typed requests",
"performance optimization"
"performance optimization",
"API caching",
"efficient data management"
]
}
},

View File

@ -1,8 +1,8 @@
{
"name": "@push.rocks/webstore",
"version": "2.0.15",
"version": "2.0.20",
"private": false,
"description": "high performance storage in the browser using indexed db",
"description": "A high-performance storage solution for web applications using IndexedDB.",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"type": "module",
@ -14,7 +14,7 @@
"buildDocs": "tsdoc"
},
"devDependencies": {
"@git.zone/tsbuild": "^2.1.76",
"@git.zone/tsbuild": "^2.1.80",
"@git.zone/tsrun": "^1.2.46",
"@git.zone/tstest": "^1.0.90",
"@push.rocks/smartntml": "^2.0.4",
@ -22,14 +22,14 @@
"@types/node": "^20.12.12"
},
"dependencies": {
"@apiglobal/typedrequest-interfaces": "^2.0.1",
"@api.global/typedrequest-interfaces": "^3.0.19",
"@push.rocks/lik": "^6.0.15",
"@push.rocks/smartenv": "^5.0.12",
"@push.rocks/smartjson": "^5.0.19",
"@push.rocks/smartpromise": "^4.0.3",
"@push.rocks/smartrx": "^3.0.7",
"fake-indexeddb": "^5.0.2",
"@tempfix/idb": "^8.0.3"
"@tempfix/idb": "^8.0.3",
"fake-indexeddb": "^5.0.2"
},
"browserslist": [
"last 1 chrome versions"
@ -56,6 +56,13 @@
"data persistence",
"storage solution",
"typed requests",
"performance optimization"
]
}
"performance optimization",
"API caching",
"efficient data management"
],
"homepage": "https://code.foss.global/push.rocks/webstore",
"repository": {
"type": "git",
"url": "https://code.foss.global/push.rocks/webstore.git"
}
}

136
pnpm-lock.yaml generated
View File

@ -8,9 +8,9 @@ importers:
.:
dependencies:
'@apiglobal/typedrequest-interfaces':
specifier: ^2.0.1
version: 2.0.1
'@api.global/typedrequest-interfaces':
specifier: ^3.0.19
version: 3.0.19
'@push.rocks/lik':
specifier: ^6.0.15
version: 6.0.15
@ -26,16 +26,16 @@ importers:
'@push.rocks/smartrx':
specifier: ^3.0.7
version: 3.0.7
'@tempfix/idb':
specifier: ^8.0.3
version: 8.0.3
fake-indexeddb:
specifier: ^5.0.2
version: 5.0.2
idb:
specifier: ^8.0.0
version: 8.0.0
devDependencies:
'@git.zone/tsbuild':
specifier: ^2.1.76
version: 2.1.76
specifier: ^2.1.80
version: 2.1.80
'@git.zone/tsrun':
specifier: ^1.2.46
version: 1.2.46(@types/node@20.12.12)
@ -54,8 +54,8 @@ importers:
packages:
'@api.global/typedrequest-interfaces@3.0.18':
resolution: {integrity: sha512-O/AdHnk9NDcBfb/Qcpi3Bq/7I6uAJHXfIT5peeKODvLUYysmuxG/c3t9NWQvfSOXQUKnVKb0WrCGjraOL7Pyww==}
'@api.global/typedrequest-interfaces@3.0.19':
resolution: {integrity: sha512-uuHUXJeOy/inWSDrwD0Cwax2rovpxYllDhM2RWh+6mVpQuNmZ3uw6IVg6dA2G1rOe24Ebs+Y9SzEogo+jYN7vw==}
'@api.global/typedrequest@3.0.21':
resolution: {integrity: sha512-iZ0+EzdaeRI6ExlN32RLM8YENCWzVOj26qaSVT5w1o0HbKH/xOOLCohsK2VhwI0nKVnOK4A6AfZV4WwqueIrrw==}
@ -243,8 +243,8 @@ packages:
'@esm-bundle/chai@4.3.4-fix.0':
resolution: {integrity: sha512-26SKdM4uvDWlY8/OOOxSB1AqQWeBosCX3wRYUZO7enTAj03CtVxIiCimYVG2WpULcyV51qapK4qTovwkUr5Mlw==}
'@git.zone/tsbuild@2.1.76':
resolution: {integrity: sha512-NmADGzasHm7p7lfCG/PGhfc2u7o/aWMhvlAIY7N/hNLD3ROkEjAzj78IUW8I0QANj13v/o11v18/IOGfSqVVRg==}
'@git.zone/tsbuild@2.1.80':
resolution: {integrity: sha512-jAChzcBFhzDKN32TzZv94l0/zegMoJnq9fvdiWV0lysRAHUjQttgwY0dFndGy3VUdlO27r0VgkNZOjiU1eB0Jg==}
hasBin: true
'@git.zone/tsbundle@2.0.15':
@ -373,6 +373,9 @@ packages:
'@push.rocks/smartfile@11.0.14':
resolution: {integrity: sha512-Y768CKzmSCHoi7di29FAHT5F4TGQqPIh5YdBNdEH0CJLkwQYsbJO98mXow3Ya7SLmL5guPhgOuSNfn7IKs5C/Q==}
'@push.rocks/smartfile@11.0.15':
resolution: {integrity: sha512-6qalAzdFTsWrx7hLBI9/a6RxpdMnRFJ8HMAGsQWeSUIIS8FxuvE357T9u89U0UM6pt0g1FUVZfks3MMd4uW8Fw==}
'@push.rocks/smarthash@3.0.4':
resolution: {integrity: sha512-HJ/fSx41jm0CvSaqMLa6b2nuNK5rHAqAeAq3dAB7Sq9BCPm2M0J5ZVDTzEAH8pS91XYniUiwuE0jwPERNn9hmw==}
@ -391,6 +394,9 @@ packages:
'@push.rocks/smartlog@3.0.3':
resolution: {integrity: sha512-E4UUSdbrf0TdSqI7LrUa3jgYQGKT6+ybSHuRcopFDt0W2/tBpY+/vPyAApJIa8iGFKJoi3oSTgYJbK90SwQwKg==}
'@push.rocks/smartlog@3.0.6':
resolution: {integrity: sha512-HvZtgur6PY+n6skw5Jx+KWwHciCiWNm+WNLkqRreuLXJrWKknwYvy/Ea+f61RqJBHEkOYTYxRoddBuC+6HAoWw==}
'@push.rocks/smartmanifest@2.0.2':
resolution: {integrity: sha512-QGc5C9vunjfUbYsPGz5bynV/mVmPHkrQDkWp8ZO8VJtK1GZe+njgbrNyxn2SUHR0IhSAbSXl1j4JvBqYf5eTVg==}
@ -461,6 +467,9 @@ packages:
'@push.rocks/smartstream@3.0.34':
resolution: {integrity: sha512-fiCcIlh3Ydduv7NAjmO5hrslZXzdJ3XQqC59WWnc3T3dqwedj7FoLjl1JfY8pWUJ0bwiikLLpKOTknJ1gSmKhA==}
'@push.rocks/smartstream@3.0.38':
resolution: {integrity: sha512-Sk9esPURWXldS0ZvgClCtrEyvELjvFnbQgUAelwoXWMfM8pXuB9BX1tE+Z1iBkB9Xyw2p1d9jYelO6waSXg0BQ==}
'@push.rocks/smartstring@4.0.15':
resolution: {integrity: sha512-NTNeOjWyg+aHtBTiQEyXamr7oTvYZ3wS1fudHo9ua7CLrykpK+i+RxFyJaLg1zB5x9xQF3NLEQecB14HPFX8Cg==}
@ -608,6 +617,9 @@ packages:
resolution: {integrity: sha512-+PmQX0PiAYPMeVYe237LJAYvOMYW1j2rH5YROyS3b4CTVJum34HfRvKvAzozHAQG0TnHNdUfY9nCeUyRAs//cw==}
engines: {node: '>=14.16'}
'@tempfix/idb@8.0.3':
resolution: {integrity: sha512-hPJQKO7+oAIY+pDNImrZ9QAINbz9KmwT+yO4iRVwdPanok2YKpaUxdJzIvCUwY0YgAawlvYdffbLvRLV5hbs2g==}
'@tempfix/watcher@2.3.0':
resolution: {integrity: sha512-a2qVQffcrnetehvwsN+LdipxQ6jejwZLgAvS9/91+C0gP4CKyikY01c0tSs0I4tSL7qHdCw1Fx0quLw+A9uyLA==}
@ -1493,6 +1505,11 @@ packages:
engines: {node: '>=16 || 14 >=14.17'}
hasBin: true
glob@10.4.1:
resolution: {integrity: sha512-2jelhlq3E4ho74ZyVLN03oKdAZVUa6UDZzFLVH1H7dnoax+y9qyaq8zBkfDIggjniU19z0wU18y16jMB2eyVIw==}
engines: {node: '>=16 || 14 >=14.18'}
hasBin: true
glob@7.2.3:
resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==}
@ -1620,9 +1637,6 @@ packages:
idb@7.1.1:
resolution: {integrity: sha512-gchesWBzyvGHRO9W8tzUWFDycow5gwjvFKfyV9FF32Y7F50yZMp7mP+T2mJIWFx49zicqyC4uefHM17o6xKIVQ==}
idb@8.0.0:
resolution: {integrity: sha512-l//qvlAKGmQO31Qn7xdzagVPPaHTxXx199MhrAFuVBTPqydcPYBWjkrbv4Y0ktB+GmWOiwHl237UUOrLmQxLvw==}
ieee754@1.2.1:
resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==}
@ -1756,6 +1770,10 @@ packages:
resolution: {integrity: sha512-N3yCS/NegsOBokc8GAdM8UcmfsKiSS8cipheD/nivzr700H+nsMOxJjQnvwOcRYVuFkdH0wGUvW2WbXGmrZGbQ==}
engines: {node: '>=14'}
jackspeak@3.1.2:
resolution: {integrity: sha512-kWmLKn2tRtfYMF/BakihVVRzBKOxz4gJMiL2Rj91WnAB5TPZumSH99R/Yf1qE1u4uRimvCSJfm6hnxohXeEXjQ==}
engines: {node: '>=14'}
js-base64@3.7.7:
resolution: {integrity: sha512-7rCnleh0z2CkXhH67J8K1Ytz0b2Y+yxTPL+/KOJoa20hfnVQ/3/T6W/KflYI4bRHRagNeXeU2bkNGI3v1oS/lw==}
@ -1891,6 +1909,10 @@ packages:
resolution: {integrity: sha512-2bIM8x+VAf6JT4bKAljS1qUWgMsqZRPGJS6FSahIMPVvctcNhyVp7AJu7quxOW9jwkryBReKZY5tY5JYv2n/7Q==}
engines: {node: 14 || >=16.14}
lru-cache@10.2.2:
resolution: {integrity: sha512-9hp3Vp2/hFQUiIwKo8XCeFVnrg8Pk3TYNPIR7tJADKi5YfcF7vEaK7avFHTlSy3kOKYaJQaalfEo6YuXdceBOQ==}
engines: {node: 14 || >=16.14}
lru-cache@6.0.0:
resolution: {integrity: sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==}
engines: {node: '>=10'}
@ -2115,6 +2137,10 @@ packages:
resolution: {integrity: sha512-jYofLM5Dam9279rdkWzqHozUo4ybjdZmCsDHePy5V/PbBcVMiSZR97gmAy45aqi8CK1lG2ECd356FU86avfwUQ==}
engines: {node: '>=16 || 14 >=14.17'}
minipass@7.1.2:
resolution: {integrity: sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==}
engines: {node: '>=16 || 14 >=14.17'}
mkdirp-classic@0.5.3:
resolution: {integrity: sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==}
@ -2284,6 +2310,10 @@ packages:
resolution: {integrity: sha512-7xTavNy5RQXnsjANvVvMkEjvloOinkAjv/Z6Ildz9v2RinZ4SBKTWFOVRbaF8p0vpHnyjV/UwNDdKuUv6M5qcA==}
engines: {node: '>=16 || 14 >=14.17'}
path-scurry@1.11.1:
resolution: {integrity: sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==}
engines: {node: '>=16 || 14 >=14.18'}
path-to-regexp@0.1.7:
resolution: {integrity: sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=}
@ -2978,11 +3008,11 @@ packages:
snapshots:
'@api.global/typedrequest-interfaces@3.0.18': {}
'@api.global/typedrequest-interfaces@3.0.19': {}
'@api.global/typedrequest@3.0.21':
dependencies:
'@api.global/typedrequest-interfaces': 3.0.18
'@api.global/typedrequest-interfaces': 3.0.19
'@push.rocks/isounique': 1.0.5
'@push.rocks/lik': 6.0.15
'@push.rocks/smartbuffer': 3.0.2
@ -2994,7 +3024,7 @@ snapshots:
'@api.global/typedserver@3.0.27':
dependencies:
'@api.global/typedrequest': 3.0.21
'@api.global/typedrequest-interfaces': 3.0.18
'@api.global/typedrequest-interfaces': 3.0.19
'@api.global/typedsocket': 3.0.0
'@push.rocks/lik': 6.0.15
'@push.rocks/smartchok': 1.0.33
@ -3031,7 +3061,7 @@ snapshots:
'@api.global/typedsocket@3.0.0':
dependencies:
'@api.global/typedrequest': 3.0.21
'@api.global/typedrequest-interfaces': 3.0.18
'@api.global/typedrequest-interfaces': 3.0.19
'@push.rocks/isohash': 2.0.1
'@push.rocks/smartjson': 5.0.19
'@push.rocks/smartrx': 3.0.7
@ -3072,7 +3102,7 @@ snapshots:
'@design.estate/dees-comms@1.0.24':
dependencies:
'@api.global/typedrequest': 3.0.21
'@api.global/typedrequest-interfaces': 3.0.18
'@api.global/typedrequest-interfaces': 3.0.19
'@push.rocks/smartdelay': 3.0.5
broadcast-channel: 3.7.0
@ -3180,13 +3210,13 @@ snapshots:
dependencies:
'@types/chai': 4.3.14
'@git.zone/tsbuild@2.1.76':
'@git.zone/tsbuild@2.1.80':
dependencies:
'@push.rocks/early': 4.0.4
'@push.rocks/smartcli': 4.0.10
'@push.rocks/smartdelay': 3.0.5
'@push.rocks/smartfile': 11.0.14
'@push.rocks/smartlog': 3.0.3
'@push.rocks/smartfile': 11.0.15
'@push.rocks/smartlog': 3.0.6
'@push.rocks/smartpath': 5.0.18
'@push.rocks/smartpromise': 4.0.3
typescript: 5.4.5
@ -3465,6 +3495,25 @@ snapshots:
glob: 10.3.12
js-yaml: 4.1.0
'@push.rocks/smartfile@11.0.15':
dependencies:
'@push.rocks/lik': 6.0.15
'@push.rocks/smartdelay': 3.0.5
'@push.rocks/smartfile-interfaces': 1.0.7
'@push.rocks/smarthash': 3.0.4
'@push.rocks/smartjson': 5.0.19
'@push.rocks/smartmime': 1.0.6
'@push.rocks/smartpath': 5.0.18
'@push.rocks/smartpromise': 4.0.3
'@push.rocks/smartrequest': 2.0.22
'@push.rocks/smartstream': 3.0.38
'@types/fs-extra': 11.0.4
'@types/glob': 8.1.0
'@types/js-yaml': 4.0.9
fs-extra: 11.2.0
glob: 10.4.1
js-yaml: 4.1.0
'@push.rocks/smarthash@3.0.4':
dependencies:
'@push.rocks/smartjson': 5.0.19
@ -3498,6 +3547,11 @@ snapshots:
'@push.rocks/isounique': 1.0.5
'@push.rocks/smartlog-interfaces': 3.0.0
'@push.rocks/smartlog@3.0.6':
dependencies:
'@push.rocks/isounique': 1.0.5
'@push.rocks/smartlog-interfaces': 3.0.0
'@push.rocks/smartmanifest@2.0.2': {}
'@push.rocks/smartmarkdown@3.0.3':
@ -3627,7 +3681,7 @@ snapshots:
'@push.rocks/smartsocket@2.0.25':
dependencies:
'@api.global/typedrequest-interfaces': 3.0.18
'@api.global/typedrequest-interfaces': 3.0.19
'@api.global/typedserver': 3.0.27
'@push.rocks/isohash': 2.0.1
'@push.rocks/isounique': 1.0.5
@ -3680,6 +3734,13 @@ snapshots:
'@push.rocks/smartpromise': 4.0.3
'@push.rocks/smartrx': 3.0.7
'@push.rocks/smartstream@3.0.38':
dependencies:
'@push.rocks/lik': 6.0.15
'@push.rocks/smartpromise': 4.0.3
'@push.rocks/smartrx': 3.0.7
'@push.rocks/webstream': 1.0.8
'@push.rocks/smartstring@4.0.15':
dependencies:
'@push.rocks/isounique': 1.0.5
@ -3925,6 +3986,8 @@ snapshots:
dependencies:
defer-to-connect: 2.0.1
'@tempfix/idb@8.0.3': {}
'@tempfix/watcher@2.3.0':
dependencies:
stubborn-fs: 1.2.5
@ -4922,6 +4985,14 @@ snapshots:
minipass: 7.0.4
path-scurry: 1.10.2
glob@10.4.1:
dependencies:
foreground-child: 3.1.1
jackspeak: 3.1.2
minimatch: 9.0.4
minipass: 7.1.2
path-scurry: 1.11.1
glob@7.2.3:
dependencies:
fs.realpath: 1.0.0
@ -5138,8 +5209,6 @@ snapshots:
idb@7.1.1: {}
idb@8.0.0: {}
ieee754@1.2.1: {}
ignore@5.3.1: {}
@ -5237,6 +5306,12 @@ snapshots:
optionalDependencies:
'@pkgjs/parseargs': 0.11.0
jackspeak@3.1.2:
dependencies:
'@isaacs/cliui': 8.0.2
optionalDependencies:
'@pkgjs/parseargs': 0.11.0
js-base64@3.7.7: {}
js-sha3@0.8.0: {}
@ -5416,6 +5491,8 @@ snapshots:
lru-cache@10.2.0: {}
lru-cache@10.2.2: {}
lru-cache@6.0.0:
dependencies:
yallist: 4.0.0
@ -5811,6 +5888,8 @@ snapshots:
minipass@7.0.4: {}
minipass@7.1.2: {}
mkdirp-classic@0.5.3: {}
mkdirp@1.0.4: {}
@ -5931,6 +6010,11 @@ snapshots:
lru-cache: 10.2.0
minipass: 7.0.4
path-scurry@1.11.1:
dependencies:
lru-cache: 10.2.2
minipass: 7.1.2
path-to-regexp@0.1.7: {}
path-to-regexp@6.2.2: {}

106
readme.md
View File

@ -1,5 +1,5 @@
# @push.rocks/webstore
high performance storage in the browser using indexed db
High performance storage in the browser using IndexedDB.
## Install
To install `@push.rocks/webstore`, use the following npm command:
@ -13,7 +13,7 @@ This will add it to your project's dependencies.
## Usage
The `@push.rocks/webstore` module provides a high-performance storage solution for web applications, leveraging IndexedDB. This guide demonstrates how to use `@push.rocks/webstore` to store, retrieve, check, and manage data in the browser efficiently.
### Setting Up
### Basic Setup
Before using `@push.rocks/webstore`, you must import and instantiate a `WebStore` class. Specify a database name (`dbName`) and a store name (`storeName`) in the options:
```typescript
@ -27,8 +27,8 @@ const myStore = new WebStore<{
});
```
### Initializing the Store
To ensure the IndexedDB is set up correctly, call the `init` method before executing CRUD operations:
### Initialization
To ensure that IndexedDB is set up correctly, call the `init` method before executing any CRUD operations:
```typescript
await myStore.init();
@ -79,9 +79,31 @@ const allKeys = await myStore.keys();
console.log(allKeys); // ['myKey', ...]
```
### Typed Request Caching
### Error Handling
One of the strengths of `WebStore` is its built-in error handling using `smartpromise`. All the asynchronous operations (`init`, `get`, `set`, `delete`, `clear`, `keys`) inherently handle errors gracefully by catching them and allowing you to handle them with standard JavaScript try-catch or using `.catch` on the promises.
#### Error Handling Example
In TypeScript, you can write try-catch blocks to handle errors:
```typescript
try {
await myStore.set('myKey', { some: 'data' });
} catch (error) {
console.error('Error storing data:', error);
}
try {
const myData = await myStore.get('myKey');
console.log(myData);
} catch (error) {
console.error('Error retrieving data:', error);
}
```
### Advanced Features: Typed Request Caching
`@push.rocks/webstore` also includes a feature for caching typed requests using the `TypedrequestCache` class. This is particularly useful for caching API requests and their responses.
#### Setting Up a Typed Request Cache
To set up a `TypedrequestCache`:
```typescript
@ -90,6 +112,7 @@ import { TypedrequestCache } from '@push.rocks/webstore';
const myCache = new TypedrequestCache('domainIdentifier');
```
#### Storing a Request and Its Response
Store a request and its response:
```typescript
@ -100,6 +123,7 @@ await myCache.setByRequest({
});
```
#### Retrieving a Cached Request
Retrieve a cached request by making a partial request:
```typescript
@ -110,7 +134,77 @@ const cachedResponse = await myCache.getByRequest({
console.log(cachedResponse); // { data: 'response data' }
```
`@push.rocks/webstore` provides a comprehensive API to leverage browser storage efficiently while maintaining high performance.
### Comprehensive Usage Example
Here is a comprehensive example that covers initialization, data manipulation, and error handling:
```typescript
import { WebStore, TypedrequestCache } from '@push.rocks/webstore';
async function main() {
const myStore = new WebStore<{
[key: string]: any;
}>({
dbName: 'myDatabase',
storeName: 'myStore',
});
try {
await myStore.init();
// Set data
await myStore.set('myKey', { some: 'data' });
console.log('Data set successfully.');
// Get data
const myData = await myStore.get('myKey');
console.log('Retrieved data:', myData); // { some: 'data' }
// Check data existence
const exists = await myStore.check('myKey');
console.log('Key exists:', exists); // true
// Delete data
await myStore.delete('myKey');
console.log('Data deleted.');
// Clear store
await myStore.clear();
console.log('Store cleared.');
// Fetch all keys
const allKeys = await myStore.keys();
console.log('All keys:', allKeys); // []
} catch (error) {
console.error('Error during storage operations:', error);
}
// Typed Request Caching
const myCache = new TypedrequestCache('exampleDomain');
try {
await myCache.setByRequest({
method: 'GET',
request: 'https://example.com/api/data',
response: { data: 'response data' }
});
console.log('Typed request cached.');
const cachedResponse = await myCache.getByRequest({
method: 'GET',
request: 'https://example.com/api/data'
});
console.log('Cached response:', cachedResponse); // { data: 'response data' }
} catch (error) {
console.error('Error during typed request caching operations:', error);
}
}
main().catch(console.error);
```
### Conclusion
The `@push.rocks/webstore` package provides a flexible and efficient way to handle browser storage and caching. With features like error handling, typed request caching, and easy-to-use APIs, it can significantly improve performance and maintainability in web applications. For further exploration, feel free to explore the source code and tests provided in the repository.
## License and Legal Information

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@push.rocks/webstore',
version: '2.0.15',
description: 'high performance storage in the browser using indexed db'
version: '2.0.20',
description: 'A high-performance storage solution for web applications using IndexedDB.'
}

View File

@ -8,11 +8,11 @@ import * as smartrx from '@push.rocks/smartrx';
export { lik, smartenv, smartjson, smartpromise, smartrx };
// apiglobal scope
import * as typedrequestInterfaces from '@apiglobal/typedrequest-interfaces';
import * as typedrequestInterfaces from '@api.global/typedrequest-interfaces';
export { typedrequestInterfaces };
// thirdparty scope
import * as idb from 'idb';
import * as idb from '@tempfix/idb';
export { idb };