pocket-state 0.1.22 → 0.1.23

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pocket-state",
3
- "version": "0.1.22",
3
+ "version": "0.1.23",
4
4
  "description": "tiny global store",
5
5
  "main": "src/index",
6
6
  "codegenConfig": {
@@ -125,7 +125,22 @@ export function createStore<T>(
125
125
  }
126
126
  }
127
127
 
128
+ function resetToInitialState() {
129
+ const cloned = Array.isArray(initialState)
130
+ ? initialState.slice()
131
+ : initialState && typeof initialState === 'object'
132
+ ? {...initialState}
133
+ : initialState;
134
+ state = cloned as T;
135
+ emitState();
136
+ }
137
+
128
138
  function reset(initialValue?: T | Partial<T>) {
139
+ if (initialState === undefined) {
140
+ resetToInitialState();
141
+ return;
142
+ }
143
+
129
144
  const isObj = (
130
145
  v: unknown,
131
146
  ): v is Record<string | symbol | number, unknown> =>