memorio 4.1.6 → 4.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -57
- package/index.cjs +436 -385
- package/index.js +436 -385
- package/{docs/markdown → markdown}/PLATFORM.md +10 -9
- package/{docs/markdown → markdown}/SECURITY.md +15 -10
- package/package.json +1 -1
- package/types/memorio.d.ts +1 -0
- package/docs/README.md +0 -307
- package/docs/_config.yml +0 -1
- /package/{docs/SUMMARY.md → SUMMARY.md} +0 -0
- /package/{docs/markdown → markdown}/CACHE.md +0 -0
- /package/{docs/markdown → markdown}/CHANGELOG.md +0 -0
- /package/{docs/markdown → markdown}/DEVTOOLS.md +0 -0
- /package/{docs/markdown → markdown}/IDB.md +0 -0
- /package/{docs/markdown → markdown}/LOGGER.md +0 -0
- /package/{docs/markdown → markdown}/OBSERVER.md +0 -0
- /package/{docs/markdown → markdown}/SESSION.md +0 -0
- /package/{docs/markdown → markdown}/STATE.md +0 -0
- /package/{docs/markdown → markdown}/STORE.md +0 -0
- /package/{docs/markdown → markdown}/USEOBSERVER.md +0 -0
package/README.md
CHANGED
|
@@ -59,12 +59,24 @@ Just import it and start storing.
|
|
|
59
59
|
|
|
60
60
|
---
|
|
61
61
|
|
|
62
|
-
##
|
|
62
|
+
## Installation options
|
|
63
63
|
|
|
64
64
|
```bash
|
|
65
|
+
# npm
|
|
65
66
|
npm i memorio
|
|
67
|
+
|
|
68
|
+
# pnpm
|
|
69
|
+
pnpm add memorio
|
|
70
|
+
|
|
71
|
+
# yarn
|
|
72
|
+
yarn add memorio
|
|
73
|
+
|
|
74
|
+
# React peer dep (optional, React ≥ 16.8)
|
|
75
|
+
npm i react react-dom
|
|
66
76
|
```
|
|
67
77
|
|
|
78
|
+
## **Setup**
|
|
79
|
+
|
|
68
80
|
```typescript
|
|
69
81
|
// memorio/index.ts — import once at your app entry point
|
|
70
82
|
import 'memorio'
|
|
@@ -113,7 +125,7 @@ state.lock() // freeze everything
|
|
|
113
125
|
state.unlock() // unfreeze
|
|
114
126
|
```
|
|
115
127
|
|
|
116
|
-
### `store` —
|
|
128
|
+
### `store` — survives refresh
|
|
117
129
|
|
|
118
130
|
```javascript
|
|
119
131
|
store.set('preferences', { theme: 'dark' })
|
|
@@ -124,7 +136,7 @@ console.debug(store.size(), 'chars stored')
|
|
|
124
136
|
console.debug(store.isPersistent) // true → real localStorage
|
|
125
137
|
```
|
|
126
138
|
|
|
127
|
-
### `session` —
|
|
139
|
+
### `session` — dies with tab
|
|
128
140
|
|
|
129
141
|
```javascript
|
|
130
142
|
session.set('token', 'user-abc-123')
|
|
@@ -140,7 +152,7 @@ const result = cache.get('temp') // undefined or the value
|
|
|
140
152
|
cache.clear() // empty it all
|
|
141
153
|
```
|
|
142
154
|
|
|
143
|
-
### `idb` —
|
|
155
|
+
### `idb` — structured & typed
|
|
144
156
|
|
|
145
157
|
```javascript
|
|
146
158
|
await idb.db.create('my-db')
|
|
@@ -236,20 +248,6 @@ Memorio runs in every JavaScript environment, with automatic fallbacks.
|
|
|
236
248
|
|
|
237
249
|
> **Why memory fallbacks on the server?** There is no browser. `store` and `session` gracefully fall back to `Map`. You still get the same API. Same `state`, same `cache`, same `useObserver`. No extra config required.
|
|
238
250
|
|
|
239
|
-
### Platform detection
|
|
240
|
-
|
|
241
|
-
Access via `memorio.*` after `import 'memorio'`:
|
|
242
|
-
|
|
243
|
-
```javascript
|
|
244
|
-
memorio.isBrowser() // true in Chrome, Firefox, Safari
|
|
245
|
-
memorio.isNode() // true in Node.js
|
|
246
|
-
memorio.isDeno() // true in Deno
|
|
247
|
-
memorio.isEdge() // true in Cloudflare Workers, Vercel Edge
|
|
248
|
-
|
|
249
|
-
const c = memorio.getCapabilities()
|
|
250
|
-
// { platform: 'browser', hasLocalStorage: true, hasIndexedDB: true, ... }
|
|
251
|
-
```
|
|
252
|
-
|
|
253
251
|
---
|
|
254
252
|
|
|
255
253
|
## Security
|
|
@@ -263,45 +261,6 @@ const c = memorio.getCapabilities()
|
|
|
263
261
|
|
|
264
262
|
---
|
|
265
263
|
|
|
266
|
-
## Installation options
|
|
267
|
-
|
|
268
|
-
```bash
|
|
269
|
-
# npm
|
|
270
|
-
npm i memorio
|
|
271
|
-
|
|
272
|
-
# pnpm
|
|
273
|
-
pnpm add memorio
|
|
274
|
-
|
|
275
|
-
# yarn
|
|
276
|
-
yarn add memorio
|
|
277
|
-
|
|
278
|
-
# React peer dep (optional, React ≥ 16.8)
|
|
279
|
-
npm i react react-dom
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
---
|
|
283
|
-
|
|
284
|
-
## Testing
|
|
285
|
-
|
|
286
|
-
```
|
|
287
|
-
95 tests · 8 suites · all passing
|
|
288
|
-
|
|
289
|
-
basic | state | store | session | cache | idb | observer | useObserver
|
|
290
|
-
```
|
|
291
|
-
|
|
292
|
-
| Suite | Tests | Status |
|
|
293
|
-
|-------|-------|--------|
|
|
294
|
-
| Basic | 7 | ✅ |
|
|
295
|
-
| State | 24 | ✅ |
|
|
296
|
-
| Store | 17 | ✅ |
|
|
297
|
-
| Session | 12 | ✅ |
|
|
298
|
-
| IDB | 7 | ✅ |
|
|
299
|
-
| Cache | 5 | ✅ |
|
|
300
|
-
| Observer | 12 | ✅ |
|
|
301
|
-
| useObserver | 12 | ✅ |
|
|
302
|
-
|
|
303
|
-
---
|
|
304
|
-
|
|
305
264
|
## License
|
|
306
265
|
|
|
307
266
|
MIT © [Dario Passariello](https://dario.passariello.ca)
|