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

@xstate/fsm

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@xstate/fsm - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

2

dist/xstate.fsm.js

@@ -1,1 +0,1 @@

var t,e;t=this,e=function(t){"use strict";t.FSM=function(t){return{initialState:{value:t.initial,actions:(e=t.states[t.initial].entry,void 0===e?[]:[].concat(e)),context:t.context},transition:function(e,n){var o,i,a="string"==typeof e?{value:e,context:t.context}:e,r=a.value,c=a.context,s="string"==typeof n?{type:n}:n,f=t.states[r];if(f.on){var u=[].concat(f.on[s.type]),l=function(e){if(void 0===e)return{value:{value:r,context:c,actions:[],changed:!1}};var n="string"==typeof e?{target:e}:e,o=n.target,i=n.actions,a=void 0===i?[]:i,u=n.cond,l=c;if((void 0===u?function(){return!0}:u)(c,s)){var y=o?t.states[o]:f,v=!1,p=[].concat(f.exit,a,y.entry).filter(Boolean).map(function(t){return"string"==typeof t?{type:t}:"function"==typeof t?{type:t.name,exec:t}:t}).filter(function(t){if("xstate.assign"===t.type){v=!0;var e=Object.assign({},l);return"function"==typeof t.assignment?e=t.assignment(l,s):Object.keys(t.assignment).forEach(function(n){e[n]="function"==typeof t.assignment[n]?t.assignment[n](l,s):t.assignment[n]}),l=e,!1}return!0}),g=o||r;return{value:{value:g,context:l,actions:p,changed:g!==r||p.length>0||v}}}};try{for(var y=function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],n=0;return e?e.call(t):{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}}(u),v=y.next();!v.done;v=y.next()){var p=l(v.value);if("object"==typeof p)return p.value}}catch(t){o={error:t}}finally{try{v&&!v.done&&(i=y.return)&&i.call(y)}finally{if(o)throw o.error}}}return{value:r,context:c,actions:[],changed:!1}}};var e},t.IS_PRODUCTION=!0,t.assign=function(t){return{type:"xstate.assign",assignment:t}},Object.defineProperty(t,"__esModule",{value:!0})},"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).FSM={});
var t,e;t=this,e=function(t){"use strict";function e(t){return"string"==typeof t?{type:t}:"function"==typeof t?{type:t.name,exec:t}:t}t.FSM=function(t){return{initialState:{value:t.initial,actions:(n=t.states[t.initial].entry,void 0===n?[]:[].concat(n)).map(e),context:t.context},transition:function(n,o){var i,a,r="string"==typeof n?{value:n,context:t.context}:n,c=r.value,s=r.context,f="string"==typeof o?{type:o}:o,u=t.states[c];if(u.on){var l=[].concat(u.on[f.type]),y=function(n){if(void 0===n)return{value:{value:c,context:s,actions:[],changed:!1}};var o="string"==typeof n?{target:n}:n,i=o.target,a=o.actions,r=void 0===a?[]:a,l=o.cond,y=s;if((void 0===l?function(){return!0}:l)(s,f)){var v=i?t.states[i]:u,p=!1,g=[].concat(u.exit,r,v.entry).filter(Boolean).map(e).filter(function(t){if("xstate.assign"===t.type){p=!0;var e=Object.assign({},y);return"function"==typeof t.assignment?e=t.assignment(y,f):Object.keys(t.assignment).forEach(function(n){e[n]="function"==typeof t.assignment[n]?t.assignment[n](y,f):t.assignment[n]}),y=e,!1}return!0}),d=i||c;return{value:{value:d,context:y,actions:g,changed:d!==c||g.length>0||p}}}};try{for(var v=function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],n=0;return e?e.call(t):{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}}(l),p=v.next();!p.done;p=v.next()){var g=y(p.value);if("object"==typeof g)return g.value}}catch(t){i={error:t}}finally{try{p&&!p.done&&(a=v.return)&&a.call(v)}finally{if(i)throw i.error}}}return{value:c,context:s,actions:[],changed:!1}}};var n},t.IS_PRODUCTION=!0,t.assign=function(t){return{type:"xstate.assign",assignment:t}},Object.defineProperty(t,"__esModule",{value:!0})},"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).FSM={});

@@ -42,7 +42,3 @@ export declare type SingleOrArray<T> = T[] | T;

export declare function FSM<TContext extends object, TEvent extends EventObject = EventObject>(fsmConfig: FSMConfig<TContext, TEvent>): {
initialState: {
value: string;
actions: any[];
context: TContext | undefined;
};
initialState: FSM.State<TContext, TEvent>;
transition: (state: string | FSM.State<TContext, TEvent>, event: string | (Record<string, any> & {

@@ -49,0 +45,0 @@ type: string;

@@ -26,2 +26,14 @@ "use strict";

exports.assign = assign;
function toActionObject(
// tslint:disable-next-line:ban-types
action) {
return typeof action === 'string'
? { type: action }
: typeof action === 'function'
? {
type: action.name,
exec: action
}
: action;
}
exports.IS_PRODUCTION = process.env.NODE_ENV === 'production';

@@ -32,3 +44,3 @@ function FSM(fsmConfig) {

value: fsmConfig.initial,
actions: toArray(fsmConfig.states[fsmConfig.initial].entry),
actions: toArray(fsmConfig.states[fsmConfig.initial].entry).map(toActionObject),
context: fsmConfig.context

@@ -67,12 +79,3 @@ },

.filter(Boolean)
.map(function (action) {
return typeof action === 'string'
? { type: action }
: typeof action === 'function'
? {
type: action.name,
exec: action
}
: action;
})
.map(toActionObject)
.filter(function (action) {

@@ -79,0 +82,0 @@ if (action.type === 'xstate.assign') {

{
"name": "@xstate/fsm",
"version": "0.2.0",
"version": "0.2.1",
"description": "XState for finite state machines",

@@ -5,0 +5,0 @@ "keywords": [

Sorry, the diff of this file is not supported yet

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