stunk 1.2.3 → 1.2.4
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 +23 -0
- package/package.json +32 -10
package/README.md
CHANGED
|
@@ -139,6 +139,8 @@ age.set(-5); // ❌ Throws an error: "Value must be non-negative!"
|
|
|
139
139
|
|
|
140
140
|
## Time Travel (Middleware)
|
|
141
141
|
|
|
142
|
+
The withHistory middleware extends a chunk to support undo and redo functionality. This allows you to navigate back and forth between previous states, making it useful for implementing features like undo/redo, form history, and state time travel.
|
|
143
|
+
|
|
142
144
|
```typescript
|
|
143
145
|
import { chunk } from "stunk";
|
|
144
146
|
import { withHistory } from "stunk/midddleware";
|
|
@@ -291,6 +293,27 @@ const counterChunk = withPersistence(chunk({ count: 0 }), {
|
|
|
291
293
|
counterChunk.set({ count: 1 });
|
|
292
294
|
```
|
|
293
295
|
|
|
296
|
+
Using Different Storage
|
|
297
|
+
|
|
298
|
+
```typescript
|
|
299
|
+
// Use sessionStorage instead of localStorage
|
|
300
|
+
const sessionStorageChunk = withPersistence(baseChunk, {
|
|
301
|
+
key: "counter",
|
|
302
|
+
storage: sessionStorage,
|
|
303
|
+
});
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
Custom Serialization
|
|
307
|
+
|
|
308
|
+
```typescript
|
|
309
|
+
// Add custom serialization/deserialization
|
|
310
|
+
const encryptedChunk = withPersistence(baseChunk, {
|
|
311
|
+
key: "encrypted-data",
|
|
312
|
+
serialize: (value) => encrypt(JSON.stringify(value)),
|
|
313
|
+
deserialize: (value) => JSON.parse(decrypt(value)),
|
|
314
|
+
});
|
|
315
|
+
```
|
|
316
|
+
|
|
294
317
|
## Async State
|
|
295
318
|
|
|
296
319
|
Async Chunks in Stunk are designed to manage asynchronous state seamlessly. They handle loading, error, and data states automatically, making it easier to work with APIs and other asynchronous operations.
|
package/package.json
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stunk",
|
|
3
|
-
"version": "1.2.
|
|
4
|
-
"description": "Stunk
|
|
3
|
+
"version": "1.2.4",
|
|
4
|
+
"description": "Stunk is a lightweight, framework-agnostic state management library for JavaScript and TypeScript. It uses chunk-based state units for efficient updates, reactivity, and performance optimization in React, Vue, Svelte, and Vanilla JS/TS applications.",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/I-am-abdulazeez/stunk"
|
|
8
|
+
},
|
|
9
|
+
"homepage": "https://github.com/I-am-abdulazeez/stunk#readme",
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/I-am-abdulazeez/stunk/issues"
|
|
12
|
+
},
|
|
5
13
|
"main": "dist/index.js",
|
|
6
14
|
"types": "dist/types/index.d.ts",
|
|
7
15
|
"scripts": {
|
|
@@ -13,19 +21,33 @@
|
|
|
13
21
|
"keywords": [
|
|
14
22
|
"state-management",
|
|
15
23
|
"atomic-state",
|
|
24
|
+
"chunk-based state",
|
|
16
25
|
"framework-agnostic",
|
|
17
|
-
"
|
|
18
|
-
"state",
|
|
19
|
-
"
|
|
20
|
-
"
|
|
26
|
+
"reactive state library",
|
|
27
|
+
"frontend state management",
|
|
28
|
+
"JavaScript state management",
|
|
29
|
+
"TypeScript state management",
|
|
21
30
|
"React state management",
|
|
22
31
|
"Vue state management",
|
|
23
|
-
"management",
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
32
|
+
"Svelte state management",
|
|
33
|
+
"recoil alternative",
|
|
34
|
+
"jotai alternative",
|
|
35
|
+
"zustand alternative",
|
|
36
|
+
"lightweight state management",
|
|
37
|
+
"state container",
|
|
38
|
+
"reusable state",
|
|
39
|
+
"efficient state updates",
|
|
40
|
+
"performance optimization",
|
|
41
|
+
"stunk",
|
|
42
|
+
"chunk"
|
|
27
43
|
],
|
|
28
44
|
"author": "AbdulAzeez",
|
|
45
|
+
"contributors": [
|
|
46
|
+
{
|
|
47
|
+
"name": "AbdulAzeez",
|
|
48
|
+
"url": "https://github.com/I-am-abdulazeez"
|
|
49
|
+
}
|
|
50
|
+
],
|
|
29
51
|
"license": "MIT",
|
|
30
52
|
"devDependencies": {
|
|
31
53
|
"@types/jest": "^29.5.14",
|