zustic 1.0.6 → 1.0.7

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/LICENSE ADDED
@@ -0,0 +1,15 @@
1
+ ISC License
2
+
3
+ Copyright (c) 2026, DeveloperRejaul
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # Zustic
4
4
 
5
- ### Lightweight State Management for Modern React Applications
5
+ ### Ultra-Lightweight State Management for Modern React Applications
6
6
 
7
7
  [![npm version](https://img.shields.io/npm/v/zustic.svg)](https://npm.im/zustic)
8
8
  [![npm downloads](https://img.shields.io/npm/dm/zustic.svg)](https://npm.im/zustic)
package/dist/index.d.mts CHANGED
@@ -1,5 +1,75 @@
1
+ /**
2
+ * Store creation function signature.
3
+ * Initializes store state and returns the initial state value.
4
+ *
5
+ * The function receives set and get utilities to manage state:
6
+ * - `set` updates partial state or via updater function
7
+ * - `get` retrieves current state
8
+ *
9
+ * @template T - Type of store state
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * type CounterState = {count: number; increment: () => void};
14
+ *
15
+ * const useCounter = create<CounterState>((set, get) => ({
16
+ * count: 0,
17
+ * increment: () => set({count: get().count + 1})
18
+ * }));
19
+ * ```
20
+ */
1
21
  type CreateParamsType<T> = (set: (partial: Partial<T> | ((state: T) => Partial<T>)) => void, get: () => T) => T;
22
+ /**
23
+ * State update parameter type.
24
+ * Can be either a partial state object or an updater function.
25
+ * Provides flexibility for both shallow and computed updates.
26
+ *
27
+ * @template T - Type of store state
28
+ *
29
+ * @example
30
+ * ```typescript
31
+ * // Partial object update
32
+ * set({count: 5});
33
+ *
34
+ * // Updater function
35
+ * set((state) => ({count: state.count + 1}));
36
+ * ```
37
+ */
2
38
  type SetSateParams<T> = Partial<T> | ((state: T) => Partial<T>);
39
+ /**
40
+ * Middleware function type for intercepting state updates.
41
+ * Follows higher-order function pattern for composability.
42
+ *
43
+ * Middlewares can:
44
+ * - Log state changes
45
+ * - Persist state to storage
46
+ * - Validate state updates
47
+ * - Handle side effects
48
+ *
49
+ * @template T - Type of store state
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * // Logger middleware
54
+ * const logger: Middleware<CounterState> = (set, get) => (next) => (partial) => {
55
+ * console.log('Updating from:', get());
56
+ * next(partial);
57
+ * console.log('Updated to:', get());
58
+ * };
59
+ *
60
+ * // Persistence middleware
61
+ * const persist: Middleware<CounterState> = (set, get) => (next) => (partial) => {
62
+ * next(partial);
63
+ * localStorage.setItem('state', JSON.stringify(get()));
64
+ * };
65
+ *
66
+ * // Use with store
67
+ * const useCounter = create(
68
+ * (set, get) => ({count: 0}),
69
+ * compose(logger, persist)
70
+ * );
71
+ * ```
72
+ */
3
73
  type Middleware<T> = (set: (partial: SetSateParams<T>) => void, get: () => T) => (next: (partial: SetSateParams<T>) => void) => (partial: SetSateParams<T>) => void;
4
74
 
5
75
  /**
package/dist/index.d.ts CHANGED
@@ -1,5 +1,75 @@
1
+ /**
2
+ * Store creation function signature.
3
+ * Initializes store state and returns the initial state value.
4
+ *
5
+ * The function receives set and get utilities to manage state:
6
+ * - `set` updates partial state or via updater function
7
+ * - `get` retrieves current state
8
+ *
9
+ * @template T - Type of store state
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * type CounterState = {count: number; increment: () => void};
14
+ *
15
+ * const useCounter = create<CounterState>((set, get) => ({
16
+ * count: 0,
17
+ * increment: () => set({count: get().count + 1})
18
+ * }));
19
+ * ```
20
+ */
1
21
  type CreateParamsType<T> = (set: (partial: Partial<T> | ((state: T) => Partial<T>)) => void, get: () => T) => T;
22
+ /**
23
+ * State update parameter type.
24
+ * Can be either a partial state object or an updater function.
25
+ * Provides flexibility for both shallow and computed updates.
26
+ *
27
+ * @template T - Type of store state
28
+ *
29
+ * @example
30
+ * ```typescript
31
+ * // Partial object update
32
+ * set({count: 5});
33
+ *
34
+ * // Updater function
35
+ * set((state) => ({count: state.count + 1}));
36
+ * ```
37
+ */
2
38
  type SetSateParams<T> = Partial<T> | ((state: T) => Partial<T>);
39
+ /**
40
+ * Middleware function type for intercepting state updates.
41
+ * Follows higher-order function pattern for composability.
42
+ *
43
+ * Middlewares can:
44
+ * - Log state changes
45
+ * - Persist state to storage
46
+ * - Validate state updates
47
+ * - Handle side effects
48
+ *
49
+ * @template T - Type of store state
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * // Logger middleware
54
+ * const logger: Middleware<CounterState> = (set, get) => (next) => (partial) => {
55
+ * console.log('Updating from:', get());
56
+ * next(partial);
57
+ * console.log('Updated to:', get());
58
+ * };
59
+ *
60
+ * // Persistence middleware
61
+ * const persist: Middleware<CounterState> = (set, get) => (next) => (partial) => {
62
+ * next(partial);
63
+ * localStorage.setItem('state', JSON.stringify(get()));
64
+ * };
65
+ *
66
+ * // Use with store
67
+ * const useCounter = create(
68
+ * (set, get) => ({count: 0}),
69
+ * compose(logger, persist)
70
+ * );
71
+ * ```
72
+ */
3
73
  type Middleware<T> = (set: (partial: SetSateParams<T>) => void, get: () => T) => (next: (partial: SetSateParams<T>) => void) => (partial: SetSateParams<T>) => void;
4
74
 
5
75
  /**