Comparing version 0.5.2 to 0.5.4
@@ -8,2 +8,7 @@ # Changelog | ||
## [0.5.4] - 2021-03-20 | ||
- **Changed:** Slightly improved typings. Most importantly, `store.state` is now typed as readonly, which should make Typescript et al warn you if you're trying to directly mutate the state object. | ||
- **Changed:** Statery now uses Typescript 4.2. | ||
## [0.5.2] - 2020-12-22 | ||
@@ -10,0 +15,0 @@ |
@@ -14,3 +14,3 @@ /** | ||
*/ | ||
state: T; | ||
state: Readonly<T>; | ||
/** | ||
@@ -45,7 +45,7 @@ * Updates the store. Accepts an object that will be (shallow-)merged into the current state, | ||
}; | ||
export declare type StateUpdateFunction<T extends State> = (state: T) => Partial<T>; | ||
export declare type StateUpdateFunction<T extends State> = (state: Readonly<T>) => Partial<T>; | ||
/** | ||
* A callback that can be passed to a store's `subscribe` and `unsubscribe` functions. | ||
*/ | ||
export declare type Listener<T extends State> = (updates: Partial<T>, state: T) => void; | ||
export declare type Listener<T extends State> = (updates: Readonly<Partial<T>>, state: Readonly<T>) => void; | ||
/** | ||
@@ -56,3 +56,3 @@ * Creates a Statery store and populates it with an initial state. | ||
*/ | ||
export declare const makeStore: <T extends Record<string | number, any>>(initialState: T) => Store<T>; | ||
export declare const makeStore: <T extends State>(initialState: T) => Store<T>; | ||
/** | ||
@@ -65,2 +65,2 @@ * Provides reactive read access to a Statery store. Returns a proxy object that | ||
*/ | ||
export declare const useStore: <T extends Record<string | number, any>>(store: Store<T>) => T; | ||
export declare const useStore: <T extends State>(store: Store<T>) => T; |
@@ -16,3 +16,4 @@ { | ||
], | ||
"version": "0.5.2", | ||
"sideEffects": false, | ||
"version": "0.5.4", | ||
"main": "dist/index.js", | ||
@@ -29,3 +30,4 @@ "module": "dist/index.esm.js", | ||
"build": "yarn clean && rollup -c", | ||
"test": "jest" | ||
"test": "jest", | ||
"docs": "typedoc src/index.ts" | ||
}, | ||
@@ -46,2 +48,3 @@ "devDependencies": { | ||
"tslib": "^2.0.3", | ||
"typedoc": "^0.20.1", | ||
"typescript": "^4.1.3" | ||
@@ -48,0 +51,0 @@ }, |
@@ -30,3 +30,3 @@ import { useEffect, useRef, useState } from "react" | ||
*/ | ||
state: T | ||
state: Readonly<T> | ||
@@ -65,3 +65,3 @@ /** | ||
export type StateUpdateFunction<T extends State> = (state: T) => Partial<T> | ||
export type StateUpdateFunction<T extends State> = (state: Readonly<T>) => Partial<T> | ||
@@ -71,3 +71,3 @@ /** | ||
*/ | ||
export type Listener<T extends State> = (updates: Partial<T>, state: T) => void | ||
export type Listener<T extends State> = (updates: Readonly<Partial<T>>, state: Readonly<T>) => void | ||
@@ -180,3 +180,3 @@ /* | ||
{ | ||
get: (_, prop: keyof T) => { | ||
get: (_, prop: string) => { | ||
/* Add the prop we're interested in to the list of props */ | ||
@@ -183,0 +183,0 @@ subscribedProps.add(prop) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
550085
30
3696
15
3