@ghostry/finity-core
Version:
Finite state management with exhaustiveness and transition enforcement for TypeScript.
2 lines • 3.8 kB
JavaScript
;let __rslib_import_meta_url__="undefined"==typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=function(e,r){for(var t in r)__webpack_require__.o(r,t)&&!__webpack_require__.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},__webpack_require__.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},__webpack_require__.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};function _array_like_to_array(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,_=Array(r);t<r;t++)_[t]=e[t];return _}function _array_with_holes(e){if(Array.isArray(e))return e}function _array_without_holes(e){if(Array.isArray(e))return _array_like_to_array(e)}function _class_call_check(e,r){if(!(e instanceof r))throw TypeError("Cannot call a class as a function")}function _define_property(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function _iterable_to_array(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _iterable_to_array_limit(e,r){var t,_,a=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var n=[],i=!0,o=!1;try{for(a=a.call(e);!(i=(t=a.next()).done)&&(n.push(t.value),!r||n.length!==r);i=!0);}catch(e){o=!0,_=e}finally{try{i||null==a.return||a.return()}finally{if(o)throw _}}return n}}function _non_iterable_rest(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _non_iterable_spread(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _sliced_to_array(e,r){return _array_with_holes(e)||_iterable_to_array_limit(e,r)||_unsupported_iterable_to_array(e,r)||_non_iterable_rest()}function _to_consumable_array(e){return _array_without_holes(e)||_iterable_to_array(e)||_unsupported_iterable_to_array(e)||_non_iterable_spread()}function _unsupported_iterable_to_array(e,r){if(e){if("string"==typeof e)return _array_like_to_array(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return _array_like_to_array(e,r)}}__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{ExhaustiveSwitchInstance:function(){return ExhaustiveSwitchInstance}});var ExhaustiveSwitchInstance=function e(r,t){var _=this;_class_call_check(this,e),_define_property(this,"state",void 0),_define_property(this,"cases",void 0),_define_property(this,"case",void 0),_define_property(this,"use",void 0),this.state=r,this.cases=t,this.case=function(e,r){return _.cases=_to_consumable_array(_.cases).concat([[e,r]]),_},this.use=function(){var e=_.state(),r=_.cases.find(function(r){var t=_sliced_to_array(r,2),_=t[0];return t[1],_.includes(e.kind)});if(r){var t=_sliced_to_array(r,2);return(t[0],t[1])(e)}throw Error("[finity] Invalid state switch!")}};for(var __webpack_i__ in exports.ExhaustiveSwitchInstance=__webpack_exports__.ExhaustiveSwitchInstance,__webpack_exports__)-1===["ExhaustiveSwitchInstance"].indexOf(__webpack_i__)&&(exports[__webpack_i__]=__webpack_exports__[__webpack_i__]);Object.defineProperty(exports,"__esModule",{value:!0});
//# sourceMappingURL=ExhaustiveSwitch.js.map