@nexcodepl/store
Advanced tools
+2
-0
@@ -10,4 +10,6 @@ import { StoreConfig, StoreReadonly, StoreSetState, StoreSubscriber } from "./types.js"; | ||
| set(setState: StoreSetState<T>): void; | ||
| set(setState: StoreSetState<T>, returnValue: "always"): T; | ||
| set(setState: StoreSetState<T>, returnValue: "updated"): T | undefined; | ||
| } | ||
| export declare function getStoreReadonly<T>(store: Store<T>): StoreReadonly<T>; | ||
| export declare function isStoreReadonly<T = unknown>(e: StoreReadonly<T> | unknown): e is StoreReadonly<T>; |
+7
-1
@@ -21,3 +21,3 @@ import { compare } from "./compare.js"; | ||
| } | ||
| set(setState) { | ||
| set(setState, returnValue) { | ||
| const newStateBase = this._config?.stateCopyFunction | ||
@@ -30,2 +30,4 @@ ? this._config.stateCopyFunction(this._state) | ||
| if (!this._config.shouldStateUpdate(this._state, newState)) { | ||
| if (returnValue === "always") | ||
| return this._state; | ||
| return; | ||
@@ -35,2 +37,4 @@ } | ||
| else if (compare(this._state, newState, 2)) { | ||
| if (returnValue === "always") | ||
| return this._state; | ||
| return; | ||
@@ -41,2 +45,4 @@ } | ||
| this._subscribersSet.forEach(s => s(this._state)); | ||
| if (returnValue) | ||
| return this._state; | ||
| } | ||
@@ -43,0 +49,0 @@ } |
+1
-1
| { | ||
| "name": "@nexcodepl/store", | ||
| "version": "1.0.13", | ||
| "version": "1.0.14", | ||
| "description": "State management library", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
11691
3.44%277
2.97%