UNPKG

keypad-fsm

Version:

Finite State Machine for a Keypad

3 lines (2 loc) 1.41 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("kingly")):"function"==typeof define&&define.amd?define(["exports","kingly"],e):e(t.Kingly={},t.kingly)}(this,function(t,e){"use strict";function n(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var i,o="PIN",r="SUBMIT",a=[e.COMMAND_RENDER,r];var u=["NUM_KEY_CLICKED","SUBMIT_CLICKED","CLEAR_CLICKED","START"];function s(t,n,i){return{updates:[{pin:""}],outputs:[{command:e.COMMAND_RENDER,params:{pin:""}}]}}function c(t,n,i){var o=t.pin+n;return{updates:[{pin:o}],outputs:[{command:e.COMMAND_RENDER,params:{pin:o}}]}}var f={initialControlState:"OFF",initialExtendedState:{pin:""},states:(n(i={},"OFF",""),n(i,o,""),n(i,"NO_PIN",""),n(i,"DONE",""),i),events:u,transitions:[{from:"OFF",event:"START",to:"NO_PIN",action:s},{from:"NO_PIN",event:"NUM_KEY_CLICKED",to:o,action:c},{from:o,event:"CLEAR_CLICKED",to:"NO_PIN",action:s},{from:o,event:"NUM_KEY_CLICKED",to:o,action:c},{from:o,event:"SUBMIT_CLICKED",to:"DONE",action:function(t,e,n){var i=t.pin;return{updates:[],outputs:[{command:r,params:{pin:i}}]}}}],updateState:function(t,e){var n=Object.assign({},t);return e.reduce(function(t,e){return Object.assign(t,e)},n)}};t.commands=a,t.events=u,t.fsmDef=f,Object.defineProperty(t,"__esModule",{value:!0})}); //# sourceMappingURL=keypad-fsm.umd.min.js.map