
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@brainstack/state
Advanced tools
@brainstack/state
A module for managing application state.
To install this module, run the following command:
npm install @brainstack/state
To use this module, import the createState function and the State interface from the module:
import { createState, State } from '@brainstack/state';
interface AppState {
count: number;
}
const initialState: AppState = {
count: 0,
};
const state: State<AppState> = createState(initialState);
state.mutate(currentState => {
return { ...currentState, count: currentState.count + 1 };
});
console.log(state.getState());
createState(initialState: T): State Creates a new state instance with the given initial state.
Arguments
initialState - The initial state of the application. Returns
A State object with the getState and mutate functions.
State A interface that represents the state management module for managing application state.
Properties
getState(selector?: (state: T) => any): any - Retrieves the current state of the application.
selector (optional) - An optional selector function to retrieve a specific value from the state.
mutate(mutator: (currentState: T) => T): T - Mutates the state of the application.
Contributions are welcome! If you would like to contribute to this module, please follow these guidelines:
Fork the repository
Create a new branch for your changes
Make your changes and commit them with descriptive commit messages
Push your changes to your fork
Submit a pull request
This module is released under the MIT License.
FAQs
A Micro State Management
The npm package @brainstack/state receives a total of 88 weekly downloads. As such, @brainstack/state popularity was classified as not popular.
We found that @brainstack/state demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.