
Research
Security News
Lazarus Strikes npm Again with New Wave of Malicious Packages
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
@alwatr/fsm
Advanced tools
A robust TypeScript library for implementing Flux (Finite) State Machines, enabling clear and organized management of application state and transitions.
A robust TypeScript library for implementing Flux (Finite) State Machines, enabling clear and organized management of application state and transitions.
@alwatr/observable
for reactive state updates.npm install @alwatr/fsm
import {FluxStateMachineBase} from '@alwatr/fsm';
// Define your states and events
type MyState = 'idle' | 'loading' | 'success' | 'error';
type MyEvent = 'fetch' | 'success' | 'error';
class MyStateMachine extends FluxStateMachineBase<MyState, MyEvent> {
constructor() {
super({
name: 'my-state-machine',
initialState: 'idle',
});
// Define state transitions
this.stateRecord_ = {
idle: {
fetch: 'loading',
},
loading: {
success: 'success',
error: 'error',
},
success: {}, // Terminal state
error: {}, // Terminal state
};
// Define actions (optional)
this.actionRecord_ = {
'on_fetch': this.handleFetch,
'on_success': this.handleSuccess,
'on_error': this.handleError,
};
}
// ... (Implement your action methods: handleFetch, handleSuccess, handleError)
// Trigger a state transition
fetchData() {
this.transition_('fetch');
}
}
FluxStateMachineBase<S extends string, E extends string>
constructor(config: {name: string; loggerPrefix?: string; initialState: S})
:
config.name
: The name of the state machine (used for logging).config.loggerPrefix
: Optional prefix for log messages.config.initialState
: The initial state of the machine.stateRecord_: StateRecord<S, E>
: Defines the states and their possible transitions based on events.
actionRecord_: ActionRecord<S, E>
: Binds action names to class methods for execution during transitions.
transition_(event: E)
: Triggers a state transition based on the provided event.
shouldTransition_(_eventDetail: StateEventDetail<S, E>): MaybePromise<boolean>
: (Optional) Allows you to define custom conditions for transitions.
postTransition__(eventDetail: StateEventDetail<S, E>)
: Executes actions associated with state transitions and events.
execAction__(name: ActionName<S, E>, eventDetail: StateEventDetail<S, E>)
: Executes a specific action if defined in the actionRecord_
.
resetToInitialState_()
: Resets the machine to its initial state without notifying subscribers.
The following companies, organizations, and individuals support flux ongoing maintenance and development. Become a Sponsor to get your logo on our README and website.
Contributions are welcome! Please read our contribution guidelines before submitting a pull request.
This project is licensed under the AGPL-3.0 License.
4.0.4 (2025-03-06)
FAQs
A robust TypeScript library for implementing Flux (Finite) State Machines, enabling clear and organized management of application state and transitions.
The npm package @alwatr/fsm receives a total of 175 weekly downloads. As such, @alwatr/fsm popularity was classified as not popular.
We found that @alwatr/fsm demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.
Security News
Opengrep continues building momentum with the alpha release of its Playground tool, demonstrating the project's rapid evolution just two months after its initial launch.