New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@simple-state-machine/core

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@simple-state-machine/core

## Installation ``` npm i @simple-state-machine/core ``` ## Quick glance - A simplest state machine can be a "Light<>Dark" Mode toggling. On click of button is toggle from `light` to `dark` or vice versa. - State diagram looks something like this for i

latest
Source
npmnpm
Version
0.1.0-alpha.3
Version published
Maintainers
1
Created
Source

Simple State Machine

Installation

   npm i @simple-state-machine/core

Quick glance

  • A simplest state machine can be a "Light<>Dark" Mode toggling. On click of button is toggle from light to dark or vice versa.
  • State diagram looks something like this for it: toggle-sm
  • Code for the above machine using the library looks like
       import {createState, createEvents, createContext, MachineConfig} from 'simple-state-machine'
    
       const states = createStates('light', 'dark');
       const events = createEvents('TOGGLE');
       const context = createContext({});
    
       const ThemeMachine = new MachineConfig(states, context, events);
    
       const {whenIn} = ThemeMachine;
       whenIn('light').on('TOGGLE').moveTo('dark');
       whenIn('dark').on('TOGGLE').moveTo('light');
    

Examples

  • Toggle Theme Machine
  • Throttling Machine in typescript

API

Keywords

state machine

FAQs

Package last updated on 15 Jan 2024

Did you know?

Socket

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.

Install

Related posts