Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fn-machine

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fn-machine - npm Package Compare versions

Comparing version 0.0.9 to 0.0.10

2

package.json
{
"name": "fn-machine",
"version": "0.0.9",
"version": "0.0.10",
"description": "a tiny functional state machine",

@@ -5,0 +5,0 @@ "main": "index",

@@ -29,15 +29,19 @@ /** @typedef {import('./fn-state').CurrentState} CurrentState */

const transition = active.transitions[transitionKey];
// if there's a transition, call it, otherwise just return the current state.
// if there's a transition, call it, otherwise just keep the current state.
const next = transition ? transition(detail, context) : {state: current, context};
// if the current state has an exit function, run it.
active.exit && active.exit();
const newState = states.find(s => s.name === next.state);
// if the new state has an enter function, run it as well.
newState.enter && newState.enter(next.context || context);
// update current
current = next.state;
// update next.context if necessary
next.context = context = next.context ? next.context : context;
// call callback with the latest state.
changeCb(next);
// we only want to run exit, enter and the callback IF a transition was run.
if (transition) {
// if the current state has an exit function, run it.
active.exit && active.exit();
const newState = states.find(s => s.name === next.state);
// if the new state has an enter function, run it as well.
newState.enter && newState.enter(next.context || context);
// update current
current = next.state;
// update next.context if necessary
next.context = context = next.context ? next.context : context;
// call callback with the latest state.
changeCb(next);
}
return next;

@@ -44,0 +48,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc