@theholocron/storage-utils 1.0.0 → 1.0.2

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.
Files changed (2) hide show
  1. package/README.md +48 -4
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,11 +1,55 @@
1
- # Storage
1
+ # `@theholocron/storage-utils`
2
2
 
3
- Storage utilities.
3
+ Namespaced session storage utilities.
4
4
 
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- npm install --save-dev @theholocron/utils-storage
8
+ pnpm add @theholocron/storage-utils
9
9
  ```
10
10
 
11
- Check out [The Holocron Archive](https://docs.theholocron.dev/projects/utilities/) for more information.
11
+ ## Usage
12
+
13
+ ```typescript
14
+ import { storage } from "@theholocron/storage-utils";
15
+
16
+ // Create a namespaced store for your app
17
+ const store = storage.session.create("my-namespace");
18
+
19
+ store.registerApp("my-app");
20
+
21
+ // Write data (supports dot-notation for nested keys)
22
+ store.sendTo("user.name", "Newton");
23
+ store.sendTo("user.role", "admin");
24
+
25
+ // Read data
26
+ store.getFrom("user"); // { name: "Newton", role: "admin" }
27
+ store.getAll(); // full storage object
28
+
29
+ // Remove a key
30
+ store.removeFrom("user.role");
31
+
32
+ // Clear all data for this namespace
33
+ store.clear();
34
+ ```
35
+
36
+ ### `storage.session.create(namespace?)`
37
+
38
+ Creates a namespaced session storage instance. The namespace defaults to `"theholocron"` (stored as `@theholocron` in `sessionStorage`).
39
+
40
+ The returned object exposes:
41
+
42
+ | Method | Description |
43
+ | ---------------------- | -------------------------------------------- |
44
+ | `registerApp(appName)` | Register an app within the namespace |
45
+ | `sendTo(key, value)` | Write a value (dot-notation for nested keys) |
46
+ | `getFrom(key)` | Read a value by key |
47
+ | `getAll()` | Return the full storage object |
48
+ | `removeFrom(key)` | Delete a key |
49
+ | `clear()` | Clear all data for the namespace |
50
+
51
+ > **Note:** Requires a browser environment — falls back gracefully when `sessionStorage` is unavailable.
52
+
53
+ ## Documentation
54
+
55
+ Check out [The Holocron Archive](https://docs.theholocron.dev/projects/utils/) for more information.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/storage-utils",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Storage utilities.",
5
5
  "homepage": "https://github.com/theholocron/utils/tree/main/packages/utils-storage#readme",
6
6
  "bugs": "https://github.com/theholocron/utils/issues",