stunk 1.2.2 → 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.
Files changed (2) hide show
  1. package/README.md +24 -1
  2. 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";
@@ -205,7 +207,7 @@ console.log(fullInfoChunk.get());
205
207
 
206
208
  Computed chunks are ideal for scenarios where state depends on multiple sources or needs complex calculations. They ensure your application remains performant and maintainable.
207
209
 
208
- ### Advanced Examples
210
+ ## Advanced Examples
209
211
 
210
212
  Form Validation Example
211
213
 
@@ -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.2",
4
- "description": "Stunk - A lightweight, framework-agnostic state management library using chunk-based units for efficient state updates.",
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
- "stunk",
18
- "state",
19
- "chunk",
20
- "react",
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
- "TypeScript state management",
25
- "reactive state library",
26
- "frontend state management"
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",